Using 3rd party jar's in plugins

26 views
Skip to first unread message

skill...@systemsbiology.net

unread,
Jan 9, 2006, 4:19:45 PM1/9/06
to cytoscape-discuss
I've written a class for one of my plugins that uses the org.jdom
libraries. I have the jdom jar referenced in my classpath, but it does
not appear to get loaded when cytoscape starts (I added -verbose to the
java call in the shell script) so I'm getting a NoClassDefError
exception when my code attempts to use it. Has anyone run across this?
Any ideas how I would get around this?

Andrea Splendiani

unread,
Jan 9, 2006, 4:33:45 PM1/9/06
to cytoscap...@googlegroups.com
If it's not available on your sdk, put it in the plugin directory. If
you still have problems (or new ones), try the extend directroy,
either throuch the -Dextend (almost) option in the command line, or
putting it in the the specific system directory for extensions. There
is a Wiki page about that.

ciao,
Andrea

Il giorno 09/gen/06, alle ore 22:19, skill...@systemsbiology.net ha
scritto:

allan_k...@agilent.com

unread,
Jan 9, 2006, 5:24:05 PM1/9/06
to cytoscape-discuss
Sarah,

The problem is that the ClassLoader used by Cytoscape to load plugins
does not know how to handle referenced or nested jars. The workaround
that many of us use in our plugins is to 'unjar' the referenced jar and
incorporate its classes into the plugin's jar.

If you are using an ant build script to build your plugin's jar, then
you can use the following target description. Note that your jdom.jar
file should be placed in the lib directory of your plugin.

<target name="jar" depends="compile" description="Creates PlugIn Jar
File.">

<unjar dest="${build.classes}">
<fileset dir="${pluginlib.dir}"/>
</unjar>

<jar destfile="${build.dir}/${plugin.name}.jar">
<fileset dir="${build.classes}"/>
</jar>
<echo message="${plugin.name}.jar is now complete. It is located in
build/ directory"/>

<copy file="${build.dir}/${plugin.name}.jar"
todir="${cytoroot.dir}/cytoscape/plugins"/>
</target>

Let me know if this helps with the problem.

AllanK

Rowan Christmas

unread,
Jan 12, 2006, 7:05:11 PM1/12/06
to cytoscap...@googlegroups.com
you can also specify for Cytoscape to load that jar by loading it as
though it were a plugin...

right now cytoscape ignores the classpath (since on many users boxes
it is out of date or wrong) so just put what hars you need after the
"-p" (for plugin) option.

java -jar cytoscape.jar -p plugins/ -p my.jar

skill...@systemsbiology.net

unread,
Jan 31, 2006, 1:02:02 PM1/31/06
to cytoscape-discuss
I've just discovered that the jar I want to use is in the the
Cytoscape/lib directory (jdom.jar). Does that make a difference for
the plugins or do I still need to use these other tricks? If it does
make a difference, how do I reference that jar? (I'm sure this is a
very basic question but I'm still getting a handle on pathing)

Thanks,
-Sarah

iliana avila-campillo

unread,
Jan 31, 2006, 1:13:12 PM1/31/06
to cytoscap...@googlegroups.com
Sarah,

If you are starting Cytoscape the normal way (using the start-up scripts, or the ant file that comes with Cytoscape) cytoscape/lib is already in your classpath. Use jdom the same way you are doing it right now (just add import statements to your java files).
-iliana
Reply all
Reply to author
Forward
0 new messages