Manipulate Java classpath to Eclipse plugin?

I am working on a plugin consisting of a homemade Eclipse view. When I run the plugin and show the classpath with System.getProperty("java.class.path")

I get this as output:D:\Programs\eclipse\plugins\org.eclipse.equinox.launcher_1.3.100.v20150511-1540.jar

I would like to add some .jar files for my view to function properly, but I cannot figure out how ... I think you can do this by adding some specs to the MANIFEST.MF of the plugin, but I donโ€™t know how. any ideas?

+3


source to share


3 answers


Each Eclipse plugin has its own classpath. To use additional banners in the plugin, you need to include them in the plugin.

Add banners to plugin directory. They are usually placed in the "lib" directory.

Open the MANIFEST.MF plugin editor and in the Runtime tab under Classpath click the Add ... button and add jars to the classpath.

On the Build tab in the editor, make sure the lib folder is included in the Binary Build section.

Your MANIFEST.MF file should have a "Bundle-Classpath" entry that looks something like this:



Bundle-ClassPath: .,
 lib/jogg-0.0.7.jar,
 lib/jorbis-0.0.15.jar,
 lib/vorbisspi1.0.2.jar

      

(here i have 3 jars in lib folder).

The build.properties file should look something like this:

bin.includes = META-INF/,\
               .,\
               plugin.xml,\
               lib/,\
               lib/jogg-0.0.7.jar,\
               lib/jorbis-0.0.15.jar,\
               lib/vorbisspi1.0.2.jar

      

+1


source


The best approach I've found is to create a directory lib

in the Eclipse project (which contains your view). Place your .jar files in the specified lib directory.

Then, using the editor at MANIFEST.MF, you add the .jar files to the classpath. If you want to export packages, you also add to exported packages. MANFIEST.MF

Depending on what you are doing, you may want / need to update your build config as well. Build configuration

If you view the file MANIFEST.MF

, you will see an entry for Bundle-ClassPath

. He will list your entries. Here it has a standard "." for the project, the directory resources/

we're exporting and a couple of .jar files.



Bundle-ClassPath: .,
resources/,
lib/aopalliance-1.0.jar,
lib/apccore-client-2.11.8.jar,
lib/cglib-nodep-2.2.2.jar,
lib/ehcache-2.10.3.jar,
...

      

Note that in our experience it is also necessary to configure the Java build path from the properties of the project itself. The user noted that this step may not be necessary. We are on an old version of Eclipse because of our product, so YMMV. If necessary (as a rule, it is an indicator to compile crashes), you need to add .jar files to the "Java Build Path" through the context menu of the project properties (you can do the same with the resource directory).

Java Build Path

This will allow you to build correctly using .jar files.

0


source


For compile time, we need to add it to the project runtime library.

During runtime, you need to package the jar either into an EAR / WAR file or upload it to the application server as application server libraries.

Please let me know if you need further help.

0


source







All Articles