Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Classpath, plugin dependencies, etc.
Classpath, plugin dependencies, etc. [message #277139] Mon, 06 December 2004 02:25 Go to next message
Eclipse UserFriend
Originally posted by: mike.morearty.com

I'm new to both Java and Eclipse. I'm having trouble getting several
plugins to see each other at runtime, even though they compile
successfully; I suspect the problems has something to do with me not
knowing how to properly use the classpath or plugin dependencies or
something like that.

Let's say I'm writing com.morearty.myplugin. One class in there calls out
to code in an *existing* third-party JAR file that I got from someone
else; let's call it thirdparty.jar. Let's say it's in C:\ThirdParty.

In trying to get everything working, I ended up adding
C:\ThirdParty\thirdparty.jar to the plugin's classpath. (Yes, I realize
this is only a temporary solution, because when I deploy this, I don't
want to force people to have a C:\ThirdParty directory. I was just trying
to get things to work.)

I did this through the GUI by right-clicking on com.morearty.myplugin in
the Package Explorer, picking "Properties", then "Java Build Path," then
"Add External JARs." I noticed that after I did this, the corresponding
line was added to the ".classpath" file in that plugin's root directory:

<classpathentry kind="lib" path="C:/ThirdParty/thirdparty.jar"/>

At this point, compilation worked fine with no errors. But when I ran,
and the code tried to load the class that referenced thirdparty.jar, I got
a java.lang.NoClassDefFoundError, referring to one of the classes in the
JAR file.

I thought, maybe I should copy thirdparty.jar into my plugin's root
directory. So I did that, and I changed the classpath to refer to this
new location (again through the GUI interface). But that didn't help.

So my questions are:

(1) What is the right way to get a plugin to "see" code from an existing
JAR file?

(2) How do I deploy it? In other words, when I do "File > Export" on my
plugin, I think the JAR file that is generated is probably not going to
have any connection to thirdparty.jar; so is there a proper way to wrap
this stuff up?

Thanks! - Mike Morearty
Re: Classpath, plugin dependencies, etc. [message #277149 is a reply to message #277139] Mon, 06 December 2004 04:33 Go to previous messageGo to next message
Eclipse UserFriend
Hi Mike,

You're already near the solution :-)

> (1) What is the right way to get a plugin to "see" code from an existing
> JAR file?
If you use existing libraries in a plugin, you should have them in the
plugin project and declare them in the manifest. The classpath is managed
automatically by the PDE.

You would put you library in a folder in the project (e.g.
<project-root>/lib/), then open the plugin manifest editor (doubleclick the
plugin.xml), go to the Runtime tab and add the library in the upper left
window (use the 'add' button). PDE adds the library then to the classpath
(if not, you can force it by right-clicking the plugin.xml > PDE Tools >
Update classpath).

> (2) How do I deploy it? In other words, when I do "File > Export" on my
> plugin, I think the JAR file that is generated is probably not going to
> have any connection to thirdparty.jar; so is there a proper way to wrap
> this stuff up?
On the plugin manifest editor, go to the Build tab. You have two trees in
the lower part, one for the binary build and one for the source build. You
have to select here everything you want to deploy. When you do Export >
Deployable plugins, PDE puts everything into the deployed version that is
declared on the Build tab. (The source for that tab is the build.properties
file in the project root).

Hope that helps,
Ciao,
Leif

> Thanks! - Mike Morearty
>
Re: Classpath, plugin dependencies, etc. [message #277197 is a reply to message #277149] Mon, 06 December 2004 12:24 Go to previous message
Eclipse UserFriend
Originally posted by: mike.morearty.com

Perfect!! Thank you Leif. -Mike



Leif Frenzel wrote:

> Hi Mike,

> You're already near the solution :-)

>> (1) What is the right way to get a plugin to "see" code from an existing
>> JAR file?
> If you use existing libraries in a plugin, you should have them in the
> plugin project and declare them in the manifest. The classpath is managed
> automatically by the PDE.

> You would put you library in a folder in the project (e.g.
> <project-root>/lib/), then open the plugin manifest editor (doubleclick the
> plugin.xml), go to the Runtime tab and add the library in the upper left
> window (use the 'add' button). PDE adds the library then to the classpath
> (if not, you can force it by right-clicking the plugin.xml > PDE Tools >
> Update classpath).

>> (2) How do I deploy it? In other words, when I do "File > Export" on my
>> plugin, I think the JAR file that is generated is probably not going to
>> have any connection to thirdparty.jar; so is there a proper way to wrap
>> this stuff up?
> On the plugin manifest editor, go to the Build tab. You have two trees in
> the lower part, one for the binary build and one for the source build. You
> have to select here everything you want to deploy. When you do Export >
> Deployable plugins, PDE puts everything into the deployed version that is
> declared on the Build tab. (The source for that tab is the build.properties
> file in the project root).

> Hope that helps,
> Ciao,
> Leif

>> Thanks! - Mike Morearty
>>
Previous Topic:How to call Superclass Selection
Next Topic:Programatically know if a plugin exists and can be loaded on the platform ?
Goto Forum:
  


Current Time: Wed Nov 05 17:09:32 EST 2025

Powered by FUDForum. Page generated in 0.04860 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top