Importing jar archives

3.88K viewsGeneral Discussion

Hi, I’m having trouble developing a plugin that uses external libraries located in a jar archive. Following the “Hello World” tutorial, could someone indicate how I can include a jar in the Eclipse project and have this exported into the plugin so that Quantrix and my class can find it?

I have tried a number of combinations, all ending with both my class and the jar archive included in the plugin jar, but Quantrix complains either of not finding the third party jar or not finding my class!



It sounds like you need to tell Eclipse to include the jar in the plugin’s runtime classpath. If you only add a jar to the build path, you might get the code to compile but the jar won’t be found at runtime.

Here’s what worked for me. I started with the “Hello World” tutorial and added a jar. I picked a jar I thought would be publicly available, jhall.jar in the com.sun.javahelp extension, but the choice of jar isn’t important.

I copied jhall.jar to my existing com.companyname.pluginname project, by drag-and-drop onto the project name. The jar appeared at the top level of the project.

I double-clicked on plugin.xml, selected the Runtime tab and clicked Add in the Classpath section. I selected jhall.jar and clicked OK. In the Package Explorer the jar moved into a “Referenced Libraries” node.

I selected the Build tab and found the jar listed in the Binary Build section. I checked the box to include the jar in the build.

I added these lines to the code:


public void performAction(QActionContext arg0, QActionEvent arg1)

HelpSet helpSet = new HelpSet();
panel.add(new JLabel(“Hello! I created ” + helpSet.publicIDString));

When I ran Quantrix and clicked on Tools / Simple Action, I saw:

Hello! I created -//Sun Microsystems Inc.//DTD JavaHelp …

I hope that helps. Please let me know either way. If it’s useful I’ll add it to the tutorial document.

Bryan Lewis
Developer, Quantrix

You are viewing 1 out of 5 answers, click here to view all answers.

Latest Questions