Home » Eclipse Projects » Eclipse Platform » Howto add an external jar dynamically to an eclipse plugin's classpath during runtime
Howto add an external jar dynamically to an eclipse plugin's classpath during runtime [message #637459] |
Fri, 05 November 2010 11:22  |
Eclipse User |
|
|
|
Hello,
one of my eclipse plugin (eclipse version 3.6.2) depends on an
external jar file which I may not include in my package because it's
proprietary third party software. The location of this file may vary
depending on where the user installs the 3dparty software in his
windows installation. During runtime I'm able find the location of the
jar file, but I don't know how to add it to the plugin's classpath. It
is not used outside of my plugin and therefore has not to be visible
to the outside.
I tried to use my own class loader (URLClassLoader) but couldn't
figure out how to make that approach working. I could load each single
Java class explicitly, but that does not resolve the loading problems
inside of the external jar file. Automatic loading was not working
because always the DefaultClassLoader was used, not the new one. I
tried to set the contextClassLoader, too, without success.
I also tried to stop the plugin from the outside (another plugin),
modify its Manifest by adding the jar file as "external:" to the
Bundle-Classpath and start it again. That approach didn't work either.
The new Manifest simply was not read.
Yet another approach was to use reflection to get access to the
private "addUrl" method of the ClassLoader as written in some
tutorials. But this method is only available in the URLClassloader not
in the DefaultClassLoader of eclipse.
Another thing I thought about was to copy the jar file during startup
to the eclipse plugin dir. I think that would not violate the license
restrictions because I would not deliver the file.
But I still wonder if there is no simple way to achieve my rather
simple task?
Can anybody help?
Thanks a lot!
Eike
|
|
| | | | | | | | | | | | | |
Re: Howto add an external jar dynamically to an eclipse plugin's classpath during runtime [message #642619 is a reply to message #642451] |
Wed, 01 December 2010 21:10   |
Eclipse User |
|
|
|
Ok, that makes alot of sense, though it seems a bit strange that the build even works when the external:${variable} form is used. So, I tried using the following:
extra.. = ${env.JBOSS_HOME}/client/commons-logging.jar,\
${env.JBOSS_HOME}/client/jboss-common-core.jar,\
etc...
No go. Appears that I need to set:
<property environment="env"/>
in build.xml for this to work. But, build.xml is generated as part of the export process, so I don't know where to set it. Am I doing this correctly? Is there something else I should be modifying?
In regards to my tweak, wouldn't the Activator be called, and thus the variable set, before OSGI tries to resolve a class contained in the bundle? Theoretically, is there anytime this wouldn't occur?
Thanks again for all of your thoughts and help.
Dan
|
|
| |
Re: Howto add an external jar dynamically to an eclipse plugin's classpath during runtime [message #643432 is a reply to message #643317] |
Mon, 06 December 2010 15:09   |
Eclipse User |
|
|
|
Thanks Paul, but I'm still having problems. Sorry to be such a problem child.
> 1) get it compiling in your workspace. For that, the extra "libs" you
> need to compile should work.
I'm not sure what you mean here. How do I refer to the extra libs?
Should putting the following in my build.properties file of the library plugin do it?
extra.. = ${env.JBOSS_HOME}/client/commons-logging.jar,\
${env.JBOSS_HOME}/client/jboss-common-core.jar,\
etc...
Currently, I get the main plugin to compile by putting the JBoss libraries on the Java Build Path.
> 2) to get it running, you can add -DJBOSS_HOME to your launch config so
> that the bundle manifest can find the libs when using $JBOSS_HOME$
Yes, this works fine.
> 3) For building, I use PDE headless build. That probably means
> specifying extra libs in the pde build.properties somewhere.
I haven't tried the PDE headless build before. Any recommended reading for instructions? I'd rather build from the eclipse UI if possible.
> I'm not sure what "export" you are using. Deploying a product from a
> ..product file? To get that to work, you'd probably have to reconcile
> steps 1 and 2 somehow.
I've been using File->Export->Deployable plug-ins and fragments to build and deploy my plugins. Seems to work fine except for interpreting the variable for the library location in extra.. = ${env.JBOSS_HOME}/...
Any help in clarifying these issues would be greatly appreciated.
|
|
| |
Goto Forum:
Current Time: Wed Jul 23 19:08:45 EDT 2025
Powered by FUDForum. Page generated in 0.04405 seconds
|