Importing jar archives

4.51K 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!



lerzegov – Yes, your understanding is correct. However, I didn’t use the BSF in the plugin, rather I just hit the jython libraries directly.

What I have done however is access the BSF when I’m in the quantrix/jython shell, and run a few commands in the Mozilla Rhino engine as an example. I imagine that it wouldn’t take much to connect this to the Quantrix objects and then run any BSF supported script this way.

dom – I’ve sucessfully added new functions to Quantrix via the jython shell — it’s fairly easy, though there is a little boilerplate (which probably could be autogenerated by some jython code). I’ve also got a quick “goal-seek” tool running, something certainly needed in Quantrix!

At the moment, the plugin is just a shell, but I’m developing this into something more full featured. This is for my own requirements at present, but if there is sufficient interest I would certainly consider releasing it.



Your work is much appreciated!

Scripting in Quantrix is one of my key wishes for a future version.
Do plan to make your Python implementation publicly available?

The most important feature I need with scripting is adding new functions to Quantrix withouth the mentionend process of plungin development/exporting etc.

Many thanks in advance.



if I understand correctly, you have developed a plugin providing a command shell form which you can execute Jython commands and procedures from inside quantrix. I suppose you have used Java BSF (bean scripting framework). Given the availability of various scritping languages for java (i.e. Groovy, Jython, Ruby) it would be nice to have configurable scripting support as a generalized feature of Quantrix. Maybe you could share some of your experience in this thread: [url:lzqe1p0c][/url:lzqe1p0c]


It works — excellent, many thanks!

I had worked all of it out except for the far-too-obvious “drag-and-drop onto the project name”. The project was previously only running in Quantrix when launched from Eclipse, but not standalone. This is now fixed.

I should mention what my plug-in does, as I know there has been some discussion here about scripting Quantrix.

My plug-in embeds Python (using the [url:212zl259][/url:212zl259] implementation), so I can now do things like interact with a model via an embedded Python shell, add functions written in Python, etc.

This is very useful, as I can now easily add further extensions, but not bother with the compile-run-debug Java/Eclipse process — I can just add to a Python script (even at runtime!).


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

Latest Questions