Loading a eclipse pluggin from jar files - java

I am trying to run a sample plugin
The extracted zip comprises of 2 jar files . So i loaded them into the eclipse by using the New->PluginDevelopment->Plugin form existing jar files wizard .
This loads the plugin but it does not run as expected . Comparing it with a sample Hello world plugin i realize that it does not have a Activator.java file and a SampleAction.java file within the src folder .
How do i get this plugin to work ? Surely there must be a way .

That example is very old and so is difficult to get going in modern eclipse. It still is a good introduction to writing debugger plugins but after you get the gist of the article, I advise looking at the current source code for any debuggers that you might be familiar with using.
You should note that there are two plugins. Keep them separate. I found it useful to extract the jar and src zip files into their respective plugin projects.
Then you have to upgrade the plugin manifest format. There should be a warning about each item that needs to changed. There might be a upgrade function in some versions of eclipse but I couldn't find in 3.7.1.
Open the manifest in the editor and select the MANIFEST.MF and plugin.xml bottom tabs to see the raw manifest. The work is mostly to move the data from plugin.xml to MANIFEST.MF. You can see it in plugin.xml and the use the editor pages to add the same information. Then delete it from plugin.xml. As you point out, one of the manifest items is the activation class. In the old plugin.xml format, this in in the Plugin/#Class attribute, so move it to the Activator field.
You'll end up with a few warnings about deprecated APIs. You can leave them or rewrite the simple functions that use them.
To run the plugins you need to run an Eclipse Application launch (run/debug configuration).
The two plugins in the example don't create main toolbars or menus. You can see that they are loaded via Help > About > Installation Details > Plug-ins. You should now be able to switch to the Debug perspective and open the Data Stack view. And, also Debug > Debug Configurations > Push Down Automata will list PDA launch configurations. Note: You can set breakpoints in .pda files (Ctrl+Shift+B) but the plugins don't implement vertical editor ruler markers so you can only see them in the Breakpoints view.

Related

How do I add LWJGL 3.1.1 to netbeans to use in a Java project?

I want to use the Light Weight Java Gaming Library(LWJGL) to my Netbeans so I can use it in my Java application. The only videos that I can find show the zip file that they downloaded with separate src and doc folders inside of it. The zip file that I download has everything in one directory. I went to lwjgl.org/download and clicked on Stable and then Generate Bundle. What am I missing?
I had the same problem recently.
So, to begin you want to go to Tools in the context menu and select Libraries (as shown). Next you can add a new library and name it e.g. LWJGL-3.1.1 confirm with ok. You can find 3 tabs in the current window Classpath, Sources and Javadoc. There you add your jar files accordingly (in the downloaded .zip file you find .jar files with different names like lwjgl-{whatever}-sources.jar or lwjgl-{whatever}-javadocs.jar) make sure you put them in the right place. You have to repeat this process for all of the jar files you want. The javadoc files are not required but recommended. Make sure you also collect all the native .dll files and merge them in a folder called \natives. You find them in these jar files that are called like: lwjgl-{whatever}-{your-OS}.jar.
Once you have finished the setup for your library right click on your current project and choose Add Library.... In the window that pops up you scroll down until you find your library that you have just created and you are almost done now.
Last but not least go to the project settings. Select Run and make sure that you set the classpath in VM options to something like in the image: -Djava.library.path="C:\java_workspace\LWJGL Library 3.1\natives. Now this classpath tells netbeans where your native files are located. Your \natives folder that you should have created in the beginning is where this path should lead to. That's it. This is all you have to do for a setup without the use of maven, gradle, ...
You can test if it is working with the code provided by LWJGL HelloWorld example.
I hope this solved your problem.
Best regards.

Eclipse Java Project - Open Declaration always opens class file instead of .java

I'm posting this query after doing lots of googling and trying out different options for last few days. Is there an easy way to attach source in Eclipse? is the closest answer I found to my question.
From above post, I tried all solutions but each time Eclipse is opening .class file instead of .java file.
Eclipse Details:
Kepler Service Release 2
Build id:20140224-0627
Please let me know if this is a bug with Eclipse or if I am missing something.
If you are using Maven, try this:
Double click on your project in eclipse -> Maven -> Enable Workspace Resolution
This is most likely because Eclipse actually use the class file for declaring the item you have requested the declaration for, and not the source file you think it should be using.
The typical reason for this is if you have a jar file containing previously compiled classes on your build path before (or instead) of the project containing the source you want. This is very rarely desirable as it can take quite a while to discover that your edits do not take effect.
Examine your build path carefully and ensure it is as you want it to be.
Maven is likely supplying a Classpath Container to your project, and generating entries for the Java Build Path based on the pom.xml contents (the JRE System Library is another example of this). Its entries will not have source attachment unless the container decides it will, which is why the Installed JREs preference page offers to let you set Source Attachments. If the pom.xml has something like that, see if you can use it. If not, see if you can configure the Maven container from its context menu. Otherwise, you may simply be stuck.
I had this same problem: when I pressed F3 or tried to open Declaration (after right click) for any element, it took me to the bytecode .class file.
My solution:
I went to the project in Project Explorer:
right click on project name->Properties
Then in Porject Properties window,
Java Build Path->"Order and Export" tab
There I selected the folder with the .java files (source code), which was below the folder having the .class files -in my case "JRE System Library [java-11-openjdk-amd64]", and pressed 'Top' button on the right frame. Then the folder with source files moved to the top.
Finally, pressed "Apply and Close" button.
That solved my problem forever and ever.
The folder
I installed a plug-in which allows me to download the sources for a maven project.
I'm not by my develop machine right now, but I think it was this:
http://marketplace.eclipse.org/content/m2e-dynamic-sources-lookup#.U8gjGWIaySM
With this, you can select a project an have maven download the sources and make then available when you navigate the code in Eclipse. All without "leaving" Eclipse.
Check into your project modules the Java Build Path, look inside the Source tab and verify if you have "Allow output folders for source folders" checkbox flagged; in this case you just need to uncheck it and you will be able to see again the right source from java files.
This is related to the Call Hierarchy in Eclipse IDE.
If you are in a situation, where you're seeing duplicate methods inside the call hierarchy showing Members calling 'myMethod(...)', double-clicking on one of the listed methods may open the .class file instead of the .java file.
When this happens, the solution is to set the search scope in the call hierarchy to Project instead of Workspace.
After setting the search scope, you won't be seeing duplicate methods listed in the call hierarchy, and double-clicking on the listed methods will only open the .java files.
(Using Eclipse DevStyle Dark Theme)

eclipse java annotation processing commit generated java classes with subclipse to svn

I'm using Java annotation processing to generate a couple of Java source files. I enabled it on the project specific settings (Properties -> Java Compile -> Annotation Processing). The generation works fine and the classes end up in the .apt_generated source folder.
Unfortunately, I'm not able to commit the generated Java source files with Subversive to the svn server. If I selected the .apt_generated source folder and perform Team -> Add to Version Control ... the dialog doesn't list any files to commit. So far, I have been committing .apt_generated source folder from the command line. Can I customize this behavior? I wasn't able to find anything on this in the team preferences.
I'm aware of the option adjusting the headless build. Since my files won't be changed to often, I just would like to commit the generated files for the moment. Thank you!
The reason for this behaviour can be found in this thread: Subversive doesn't allow to commit "derived" resources. The folder used by the annotation processing and all contained resources automatically get the "derived" flag, which you can verify on their Properties->Resource page.
I'm in a similar situation as you wanting to commit generated files at least initially. There is a plugin that apparently makes it possible to override the behaviour of setting the "derived" flag, which I'm going to test now: AutoDeriv
Since this has been unanswered for over a year, I'll take a stab at it. I had a similar problem with Eclipse's .project and .classpath files, which I wanted maintained in Subversion.
I believe you may have to tell Eclipse not to ignore "resources." These are files that have extensions but no names (e.g. .project or .classpath or .apt_generated). From Eclipse's Project Explorer click on the View Menu icon (the upside down triangle icon). Then Customize View... then remove the check from the checkbox labeled .* resources.

Eclipse Plug-in development. Can i use an already existing jar file with my plug in?

Im writing a server based application and i would like eclipse to be able to interact with it.
I was wondering if eclipse PDE can handle using an external jar to interact with RabbitMQ. Also would i have access to the editor i.e. could the server respond and then update the code on the users end inside the editor pane?
Also if anyone knows any good resources for eclipse plug-in development that would be great as the only books i can find on amazon are a few years old
Thanks,
Ben
You can include any JAR in your plugin and write code that uses it.
Copy the JAR into your plugin project (usually they're placed into a lib folder in the project).
Open your plugin's manifest or plugin.xml file and go to the Runtime tab.
In the Classpath section, use the Add... button to add the JAR.
Go to the Build tab and make sure the JAR is selected at least for the Binary Build.
Save.
Now you should be able to write code that uses the JAR and when you build your plugin it will be packaged in your plugin.
If you find that you'll be writing multiple plugins that go together and all use the same JAR(s), there's a better way to package it, but I'll leave those details out for now.

sHow do I add external JAR files in a Web Free Form Application in NetBeans?

I have a Red5 application that i want to work on using NetBeans 6.8.
I know I can use a web Free-Form Application, the only problem that I'm having is to add external jar files.
When I go to the project's properties, Where exactly do I add the external jars that I need in order to properly compile the application?
update
i think that the following URL addresses my problem but i can't really understand the solution.
http://www.bradmcevoy.com/blogs/netbeans_ant_ivy.html
You can add the external libraries to your project's Libraries folder, or you can add them in the NetBeans' Tools > Libraries dialog. The latter can be shared among several projects. This answer includes illustrations.
Addendum: For free-form type projects, the Projects > Properties mentions, "Any settings modified on this panel are for IDE purpose only and do not change the build script. If you want to make changes in build process, please modify your build script manually."
found a solution here but it's probably for a lower version of netbeans:
http://forums.netbeans.org/viewtopic.php?p=5329
i get an error on the tag.
Since it is a free-form project, you have to make sure that your build script puts the correct jars into the compile-time classpath. You also want to make your Netbeans project libraries match for auto-complete purposes and error highlighting and such (ie when you view Project Properties->Java Sources ClassPath).
Ok I finally resolved the issue by re-creating the project using the step by step tutorial in the following URL : http://blogs.oracle.com/coreqa/entry/setting_up_freeform_project_correctly

Categories

Resources