Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Jar-in-a-jar
Jar-in-a-jar [message #211403] Sun, 20 May 2007 16:55 Go to next message
Eclipse UserFriend
Originally posted by: ZioNemo.hotmail.com

Hi all,
The problem is quite simple:
I have an application that uses some non-standard libraries (freemarker &
grappa) that come as standalone .jar files (freemarker.jar &
grappa1_2.jar).
I put those in a nice subdirectory in my project (lib) and instructed
eclipse to look into that.
All is good.
I can run my application from the IDE.
Now I'm exporting my Application as a .jar file and I selected to export
the lib/*.jar files.
Eclipse dutifully includes my lib subdirectory in the .jar file.
Unfortunately java seems unable to access these "included" jars and I have
to manually extract from the jar lib and all its contents to have them
alongside the main application jar.
Is there some way to avoid this step?
I *think* (I didn't actually try) I could extract the lib/jars content and
include it in my jar, but it seems rather messy. Is there any other
(possibly better) solution? Can I convince eclipse to do this for me?

Other related (possibly harder) issue: I also have an executable I use as
a filter and I launch using ProcessBuilder.start() (I actually have
several executables, obviously, one for each platform I need to run on).
This executable is in the /lib subdirectory in my application jar file. Is
there any way to run it from there without explicitly extracting it?

Thanks in Advance
ZioNemo
Re: Jar-in-a-jar [message #211412 is a reply to message #211403] Sun, 20 May 2007 18:38 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: news.pellaton.li

Hi

Java does in general - this is not an Eclipse isse - not recursively
unpack JAP files. However, there are three solutions for your
problem I would consider:
1) deploy the jars separately and write a small script that correctly
assembles the classpath and runs your application
2) http://fjep.sourceforge.net/
3) unpack the external jars and repack them in a single jar including
your classes too. Some programs (especially some framework
components) even rename the packages of their dependencies to avoid
problems with different versions of the in the target environment.

HTH,

Michael
Re: Jar-in-a-jar [message #211470 is a reply to message #211412] Mon, 21 May 2007 13:34 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eclipse5.rizzoweb.com

Michael Pellaton wrote:
> Hi
>
> Java does in general - this is not an Eclipse isse - not recursively
> unpack JAP files. However, there are three solutions for your
> problem I would consider:
> 1) deploy the jars separately and write a small script that correctly
> assembles the classpath and runs your application
> 2) http://fjep.sourceforge.net/
> 3) unpack the external jars and repack them in a single jar including
> your classes too. Some programs (especially some framework
> components) even rename the packages of their dependencies to avoid
> problems with different versions of the in the target environment.

You should be aware that distributing your application with options 2
and 3 above will violate the license terms of some libraries. Before
distributing in either of those ways you should review the licenses to
make sure - or better yet, have an attorney who is experienced with
software licensing review them.

Hope this helps,
Eric
Re: Jar-in-a-jar [message #211498 is a reply to message #211470] Mon, 21 May 2007 16:16 Go to previous message
Eclipse UserFriend
Originally posted by: ZioNemo.hotmail.com

Eric Rizzo wrote:

> Michael Pellaton wrote:
>> Hi
>>
>> Java does in general - this is not an Eclipse isse - not recursively
>> unpack JAP files. However, there are three solutions for your
>> problem I would consider:
>> 1) deploy the jars separately and write a small script that correctly
>> assembles the classpath and runs your application
>> 2) http://fjep.sourceforge.net/
>> 3) unpack the external jars and repack them in a single jar including
>> your classes too. Some programs (especially some framework
>> components) even rename the packages of their dependencies to avoid
>> problems with different versions of the in the target environment.

> You should be aware that distributing your application with options 2
> and 3 above will violate the license terms of some libraries. Before
> distributing in either of those ways you should review the licenses to
> make sure - or better yet, have an attorney who is experienced with
> software licensing review them.

Thanks to all,
I actually chose option (4) :) ;) :)

I packed all libraries (jars and executables) in the main JAR.
Then I wrote a small initialization script in my main() that checks if the
lib subdirectory exists and, if needed, creates it extracting from the JAR
itself.

It seems to work.

One little quirk: I must explicitly give the JAR name to the
JAR-extraction class. Is there any way to get the name of the JAR
containing a certain class? something like
this.getClass().getContainingJar() or the like?

Thanks
ZioNemo
Previous Topic:Screen Shot the eclipse workspace.
Next Topic:How to move a Java application to be a eclipse plug-in
Goto Forum:
  


Current Time: Fri Apr 26 21:12:52 GMT 2024

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

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

Back to the top