Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » plugin classpath util jars
plugin classpath util jars [message #144931] Thu, 16 October 2003 14:42 Go to next message
No real name is currently offline No real nameFriend
Messages: 8
Registered: July 2009
Junior Member
Hi,

What is the (correct) way to include utility jar files into the plugin. And,
ofcourse, ship them with the deployable jar for the update site.

My project has a src folder (default)
My project has also a lib folder where several util jars reside.
I put these jar file in the java build path on the properties page of the
java plugin project.
Doing so does make the code compile. But when i run the plugin using the
runtime workbench these jar files are not in the classpath.

I tried to put them in the build.properties like this:
source.<project>.jar=src/
bin.includes=plugin.xml,\
*.jar,\
icons,\
<project>.jar,\
lib/*.jar

I also tried to add the jar files to the runtime tab of the plugin.xml like
lib/util.jar which results in:
<library name="lib/util.jar"><export name="*"/></library>

This doesn't work. Does anybody have a solution?
Is there a difference in how this must be configured using runtime workbench
and the actual export for the update site?
Re: plugin classpath util jars [message #144965 is a reply to message #144931] Thu, 16 October 2003 15:13 Go to previous messageGo to next message
rich boakes is currently offline rich boakesFriend
Messages: 76
Registered: July 2009
Member
Hi,

S.Witte wrote:
> What is the (correct) way to include utility jar files into the
> plugin. And, of course, ship them with the deployable jar for
> the update site.

Recently I've gone down the path of creating a separate plugin for each
utility jar that I need to ship (setting the plugin version number to
match the release number of the wrapped jar file). In this way I'm able
to set library dependencies based on the eclipse model, and not
re-package the same libraries for every different feature variant I want
to ship.

Aside: I've started to wonder about the merit of a central Eclipse
repository for jar's that have been wrapped, and the possibility of an
automated lookup in cases where a class is not found... then download on
demand.

> I tried to put them in the build.properties like this:
> source.<project>.jar = src/
> bin.includes = plugin.xml,\
> *.jar,\
> icons,\
> <project>.jar,\
> lib/*.jar


A cautionary tale - if you're using wildcards in your bin.includes, be
sure not to include the directory where your output jar file will end up
- if you do, subsequent builds will recursively include the old output
jar from the previous build, eventually making it huge.

i.e. lose the first "*.jar".

source.<project>.jar = src/
bin.includes = plugin.xml,\
icons,\
<project>.jar,\
lib/*.jar

As for your error: this is a long-shot, but since everything else seems
normal... your problem *may* be in your build.xml file - did you
generate it before or after you populated the build.properties file?
(you have to do it after)

To be sure, try unzipping your output jar file and seeing if all the
expected content is there.

HTH

rich
--
Re: plugin classpath util jars [message #145503 is a reply to message #144965] Fri, 17 October 2003 08:03 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 8
Registered: July 2009
Junior Member
Thanks for your reaction.
The problem is still not solved.
I use the correct build order.
1. edit plugin.xml
2. edit build.properties
3. create ant build file
4. run build.xml.

Is it correct to put these util jars in the plugin.xml as:
<runtime>
<library name="<project>.jar"> <!-- the project jar file -->
<export name="*"/>
</library>
<library name="lib/util.jar"> <!-- the util jar file -->
<export name="*"/>
</library>
</runtime>

The uitl libraries do not appear in the <project>.jar wich is created by the
build.xml.

If i create a feature project and then a site project and build the site,
the end jar file does include the lib/util.jar files. These jars are not on
the classpath of the plugin when i run the plugin after the install via the
update manager. I get class not found exceptions.

Any idea how to put thes jar files on the class path for both the
deliverable and the runtime-workbench.
Re: plugin classpath util jars [message #145527 is a reply to message #145503] Fri, 17 October 2003 08:58 Go to previous messageGo to next message
rich boakes is currently offline rich boakesFriend
Messages: 76
Registered: July 2009
Member
S.Witte wrote:

> Thanks for your reaction.
> The problem is still not solved.
> I use the correct build order.
> 1. edit plugin.xml
> 2. edit build.properties
> 3. create ant build file
> 4. run build.xml.

These steps look normal.

> Is it correct to put these util jars in the plugin.xml as:
> <runtime>
> <library name="<project>.jar"> <!-- the project jar file -->
> <export name="*"/>
> </library>
> <library name="lib/util.jar"> <!-- the util jar file -->
> <export name="*"/>
> </library>
> </runtime>

Yep. I'd expect to see something like this.

> The uitl libraries do not appear in the <project>.jar wich is created by the
> build.xml.

That's not good. They should be there. The content of your jar file
should be something like:

/plugin.xml
/<project.jar>
/lib/util.jar

ideas...
1 - have you tried explicitly defining the jar path rather
than using a wildcard:

source.<project>.jar=src/
bin.includes=plugin.xml,\
lib/util.jar
<project>.jar,\
icons

2 - after you create the build file, have a look at it and see if
util.jar is mentioned - check that you're running the appropriate ant
target (e.g. build.update.jars).

> Any idea how to put thes jar files on the class path for both the
> deliverable and the runtime-workbench.

There is no difference, this is likely to be a head-slapping "oh, that"
problem - it's just a pain until you get to that point.

Rich
Re: plugin classpath util jars [message #145534 is a reply to message #145527] Fri, 17 October 2003 09:00 Go to previous messageGo to next message
rich boakes is currently offline rich boakesFriend
Messages: 76
Registered: July 2009
Member
oops - this:

> source.<project>.jar=src/
> bin.includes=plugin.xml,\
> lib/util.jar
> <project>.jar,\
> icons

should read:

source.<project>.jar=src/
bin.includes=plugin.xml,\
lib/util.jar, \
<project>.jar,\
icons

(though without testing i'm not sure if "icons" and not "icons/*" will work)
Re: plugin classpath util jars [message #145611 is a reply to message #145527] Fri, 17 October 2003 11:11 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 8
Registered: July 2009
Junior Member
> That's not good. They should be there. The content of your jar file
> should be something like:
>
> /plugin.xml
> /<project.jar>
> /lib/util.jar

Whatever i try this is not the output. The jar file actually contains the
class files of the plugin project that is in the snipped above
<project>.jar.
So it does not result in a jar file wich holds the plugin project.

> ideas...
> 1 - have you tried explicitly defining the jar path rather
> than using a wildcard:

Yes, makes no difference.

> 2 - after you create the build file, have a look at it and see if
> util.jar is mentioned - check that you're running the appropriate ant
> target (e.g. build.update.jars).

This was new for me, i tried this and the ouput is:
/plugin.xml
/<project.jar>

and no /lib/util.jar !

Isn't this what the site project does for me? Do i need this for running it
via the runtime-workbench?
Re: plugin classpath util jars [message #145753 is a reply to message #145611] Fri, 17 October 2003 14:18 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 8
Registered: July 2009
Junior Member
Ok, my jar file looks good now:
/project.jar
/plugin.xml
/plugin.properties
/lib/util1.jar
/lib/util2.jar

But, when i run this, either with the runtim-workbench or install it via the
update manager, i get class not found exceptions for classes in util1.jar so
this jar is not on the class path.

It is however defined in the plugin.xml:

....
<runtime>
<library name="project.jar">
<export name="*"/>
</library>
<library name="lib/util1.">
<export name="*"/>
</library>
<library name="lib/util2.jar">
<export name="*"/>
</library>
<runtime>
....

My build.properties looks like:

bin.includes= plugin.xml, \
plugin.properties,\
lib/*.jar
project.jar
icons/

source.project.jar=src/

The libraries are on the class path via the properties-java build path and
are checked for export for depended projects.

In the preferences-Plugin Development-Java build path control "use classpath
containers for dependent plugins" is checked.

The 'run' parameters for running as runtime-workbench are all default.

Does anybody have a clou how to get these util libraries on the classpath?
Re: plugin classpath util jars [message #145810 is a reply to message #145753] Fri, 17 October 2003 14:34 Go to previous messageGo to next message
Jerome Lanneluc is currently offline Jerome LannelucFriend
Messages: 572
Registered: July 2009
Senior Member
You wrote:
<library name="lib/util1.">
<export name="*"/>
</library>

Did you mean:
<library name="lib/util1.jar">
<export name="*"/>
</library>
?

"S.Witte" <switte@eniac.nl> wrote in message news:bmotii$f4$1@eclipse.org...
> Ok, my jar file looks good now:
> /project.jar
> /plugin.xml
> /plugin.properties
> /lib/util1.jar
> /lib/util2.jar
>
> But, when i run this, either with the runtim-workbench or install it via
the
> update manager, i get class not found exceptions for classes in util1.jar
so
> this jar is not on the class path.
>
> It is however defined in the plugin.xml:
>
> ...
> <runtime>
> <library name="project.jar">
> <export name="*"/>
> </library>
> <library name="lib/util1.">
> <export name="*"/>
> </library>
> <library name="lib/util2.jar">
> <export name="*"/>
> </library>
> <runtime>
> ...
>
> My build.properties looks like:
>
> bin.includes= plugin.xml, \
> plugin.properties,\
> lib/*.jar
> project.jar
> icons/
>
> source.project.jar=src/
>
> The libraries are on the class path via the properties-java build path and
> are checked for export for depended projects.
>
> In the preferences-Plugin Development-Java build path control "use
classpath
> containers for dependent plugins" is checked.
>
> The 'run' parameters for running as runtime-workbench are all default.
>
> Does anybody have a clou how to get these util libraries on the classpath?
>
>
Re: plugin classpath util jars [message #145938 is a reply to message #145810] Fri, 17 October 2003 18:49 Go to previous messageGo to next message
rich boakes is currently offline rich boakesFriend
Messages: 76
Registered: July 2009
Member
Lets take a step back to ensure we're answering the right questions :)

The original post had two questions - one involved how to package for
deployment and one involved a problem with runtime testing.

1: For deployment, there are two jars that you need to build.

Jar 1: contains class files plus anything "non-java"
in your source directory - this is the jar that
becomes <project>.jar.

Jar 2: contains <project>.jar, plus any files you list in
the build.properties file. This is the jar which can then be
packaged up in a feature and distributed.

Both these jars are created automatically by Ant.

2: For development, you don't need to build any jars - painful
experience taught me that it's 99.9% down to the plugin.xml file
(perhaps someone can confirm this). I've had a poke around
in the runtime-workspace .registry file and it's contained a
reference to the root my original projects, rather than copying
them over.

So the error you're getting in development is more likely to
do with some other problem.

Idea:

Are you *sure* the classes you mention really are in util.jar?
i.e. Could they be being picked up from somewhere else at compile
time, meaning you don't see the problem until you have your
runtime failure?


To be sure, I worked a quick example through.

1. create a java plugin with a view (Test2Plugin)
2. add "lib" directory
3. add "lib/stuff.jar"
4. look in stuff.jar and find an instantiable class.
5. edit Test2Plugin.java to contain an instance of that class
6. notice the red wiggly line because stuff.jar is not
yet on the classpath
7. add stuff.jar to the classpath (using properties wizard)
8. in Test2Plugin.java do an "Organise Imports".
9. No more red sea - class compiles successfully.
10. Run the plugin.
11. Plugin errors (NoClassDefFoundException) - yay!
12. Edit plugin.xml. In the runtime tab there is "Test2.jar"
so add the run-time library "lib/Stuff.jar"
(the xml now looks like this)
<runtime>
<library name="Test2.jar"/>
<library name="lib/Stuff.jar"/>
</runtime>
13. Unlucky for some - run it again - it works.

Can you go through this process and get the same result?

Rich
Re: plugin classpath util jars [message #146409 is a reply to message #145938] Mon, 20 October 2003 08:09 Go to previous message
No real name is currently offline No real nameFriend
Messages: 8
Registered: July 2009
Junior Member
:-)

It works now!
I had a hard time figuring out what the problem was but after some testing i
found that i cannot
package prefix any of the jars, not the project jar and not the util jars!
As soon as one package prefix is defined the class path gets confused.

This is strange isn't it?

Rich, thanks a lot!

"rich boakes" <rich.boakes@port.ac.uk> wrote in message
news:bmpdi3$fja$1@eclipse.org...
> Lets take a step back to ensure we're answering the right questions :)
>
> The original post had two questions - one involved how to package for
> deployment and one involved a problem with runtime testing.
>
> 1: For deployment, there are two jars that you need to build.
>
> Jar 1: contains class files plus anything "non-java"
> in your source directory - this is the jar that
> becomes <project>.jar.
>
> Jar 2: contains <project>.jar, plus any files you list in
> the build.properties file. This is the jar which can then be
> packaged up in a feature and distributed.
>
> Both these jars are created automatically by Ant.
>
> 2: For development, you don't need to build any jars - painful
> experience taught me that it's 99.9% down to the plugin.xml file
> (perhaps someone can confirm this). I've had a poke around
> in the runtime-workspace .registry file and it's contained a
> reference to the root my original projects, rather than copying
> them over.
>
> So the error you're getting in development is more likely to
> do with some other problem.
>
> Idea:
>
> Are you *sure* the classes you mention really are in util.jar?
> i.e. Could they be being picked up from somewhere else at compile
> time, meaning you don't see the problem until you have your
> runtime failure?
>
>
> To be sure, I worked a quick example through.
>
> 1. create a java plugin with a view (Test2Plugin)
> 2. add "lib" directory
> 3. add "lib/stuff.jar"
> 4. look in stuff.jar and find an instantiable class.
> 5. edit Test2Plugin.java to contain an instance of that class
> 6. notice the red wiggly line because stuff.jar is not
> yet on the classpath
> 7. add stuff.jar to the classpath (using properties wizard)
> 8. in Test2Plugin.java do an "Organise Imports".
> 9. No more red sea - class compiles successfully.
> 10. Run the plugin.
> 11. Plugin errors (NoClassDefFoundException) - yay!
> 12. Edit plugin.xml. In the runtime tab there is "Test2.jar"
> so add the run-time library "lib/Stuff.jar"
> (the xml now looks like this)
> <runtime>
> <library name="Test2.jar"/>
> <library name="lib/Stuff.jar"/>
> </runtime>
> 13. Unlucky for some - run it again - it works.
>
> Can you go through this process and get the same result?
>
> Rich
>
Previous Topic:Profiler plug-in for Eclipse.
Next Topic:Cursor Symbol
Goto Forum:
  


Current Time: Fri Sep 27 08:15:26 GMT 2024

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

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

Back to the top