[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.platform] Classpath, plugin dependencies, etc.

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