Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > jar assembling tool ...?

Reply
Thread Tools

jar assembling tool ...?

 
 
Malte
Guest
Posts: n/a
 
      04-23-2005
Giovanni Azua wrote:
> Hello all,
>
> Every time I want to deploy a jar being whether a Swing app
> or Java API inside Oracle I make the jar contain all dependencies
> like e.g. xerces.jar this avoids the need to configure class path
> at client side etc. This works nicely but my jars get quite inflated ...
> is there any tool for finding and assembling jars including from
> dependencies ONLY the needed classes and not the whole
> dependency jars ...
>
> A clear example is Log4J, in order to include the latest version
> -even if you only use the very basic functionality- you have to
> burden with all the e.g. jmx, viewer and lf5 packages ...
>
> I think a tool like this should be able to:
>
> - examine your jar parse it to get exactly all dependencies
> - examine recursively all dependencies for dependencies
> -of course- leaving out those that come with the JRE.
> - Build a new jar containing only what's needed ...
>
> If this kind of tool does not exist would you agree it should
> have a good market?
>
> Thanks in advance,
> Best Regards,
> Giovanni
>
>

Oracle JDeveloper does this.
 
Reply With Quote
 
 
 
 
Giovanni Azua
Guest
Posts: n/a
 
      04-23-2005
Hello all,

Every time I want to deploy a jar being whether a Swing app
or Java API inside Oracle I make the jar contain all dependencies
like e.g. xerces.jar this avoids the need to configure class path
at client side etc. This works nicely but my jars get quite inflated ...
is there any tool for finding and assembling jars including from
dependencies ONLY the needed classes and not the whole
dependency jars ...

A clear example is Log4J, in order to include the latest version
-even if you only use the very basic functionality- you have to
burden with all the e.g. jmx, viewer and lf5 packages ...

I think a tool like this should be able to:

- examine your jar parse it to get exactly all dependencies
- examine recursively all dependencies for dependencies
-of course- leaving out those that come with the JRE.
- Build a new jar containing only what's needed ...

If this kind of tool does not exist would you agree it should
have a good market?

Thanks in advance,
Best Regards,
Giovanni


 
Reply With Quote
 
 
 
 
Jacob
Guest
Posts: n/a
 
      04-23-2005
Giovanni Azua wrote:

> Every time I want to deploy a jar being whether a Swing app
> or Java API inside Oracle I make the jar contain all dependencies


Isn't there a legal aspect of this?
I would think at least some licenses prohibit such rebundling?

 
Reply With Quote
 
Daniel Dyer
Guest
Posts: n/a
 
      04-23-2005
On Sat, 23 Apr 2005 13:08:27 +0100, Giovanni Azua <(E-Mail Removed)>
wrote:

> Hello all,
>
> Every time I want to deploy a jar being whether a Swing app
> or Java API inside Oracle I make the jar contain all dependencies
> like e.g. xerces.jar this avoids the need to configure class path
> at client side etc. This works nicely but my jars get quite inflated ...
> is there any tool for finding and assembling jars including from
> dependencies ONLY the needed classes and not the whole
> dependency jars ...


You don't need to do this to avoid setting a classpath, just set the
classpath in the manifest. As somebody else mentioned, if any of your
jars are proprietary third-party libraries (JDBC drivers for example),
this would almost certainly be a breach of the licence.

However, if you still want to do this, I think some obfuscators have
options to strip out all unused classes.

Dan.


--
Daniel Dyer
http://www.footballpredictions.net
 
Reply With Quote
 
Giovanni Azua
Guest
Posts: n/a
 
      04-23-2005
Hello Malte,

"Malte" <(E-Mail Removed)> wrote in message
> Oracle JDeveloper does this.
>

I precisely use JDeveloper, it does not do this.

JDeveloper has the option to build a fat jar including all
dependencies but it does NOT wipe out unused parts (packages
and classes) of the dependencies list ...

You always get with JDeveloper a very fat jar ... this quickly
becomes unmanageable when you have many dependencies
and you do not want to hack into the dependencies (removing
it manually on your own) also because then you would need to
do it each time any of the dependencies gets updated or you just
want to get the new functionality ...

Best Regards,
Giovanni


 
Reply With Quote
 
Giovanni Azua
Guest
Posts: n/a
 
      04-23-2005
Hello Jacob,

"Jacob" <(E-Mail Removed)> wrote in message
> Isn't there a legal aspect of this?
> I would think at least some licenses prohibit such rebundling?
>

Probably for *some* of the existing open src jars yes
likely not for all of the existing open src ... besides I always build
jars as components which I reuse for myself then you really
want to have this functionality ...

I wonder if Eclipse has this or any plugin???

Another one is AnT probably has an option for this ...

I will research a bit ...

Regards,
Giovanni


 
Reply With Quote
 
Marcus
Guest
Posts: n/a
 
      04-23-2005
Giovanni Azua wrote:

>Hello all,
>
>Every time I want to deploy a jar being whether a Swing app
>or Java API inside Oracle I make the jar contain all dependencies
>like e.g. xerces.jar this avoids the need to configure class path
>at client side etc. This works nicely but my jars get quite inflated ...
>is there any tool for finding and assembling jars including from
>dependencies ONLY the needed classes and not the whole
>dependency jars ...
>
>A clear example is Log4J, in order to include the latest version
>-even if you only use the very basic functionality- you have to
>burden with all the e.g. jmx, viewer and lf5 packages ...
>
>I think a tool like this should be able to:
>
>- examine your jar parse it to get exactly all dependencies
>- examine recursively all dependencies for dependencies
> -of course- leaving out those that come with the JRE.
>- Build a new jar containing only what's needed ...
>
>If this kind of tool does not exist would you agree it should
>have a good market?
>
>Thanks in advance,
>Best Regards,
>Giovanni
>
>
>
>

Hi Giovanni,

There are probably many tools that will allow you to do this, but from
my experience it could end up being more of a hassle than you imagine.
Say for example that you bundle log4j with your jar. If a bug is found
in log4j, then the only way to update your app is to re-package it.
Whereas if you keep your jars separate, you only need to update the
log4j lib.

Basically, when it comes down to it, packaging things separately is done
for a reason. There is nothing to stop you bundling everything, but it
will come back to bite you one day.
 
Reply With Quote
 
Giovanni Azua
Guest
Posts: n/a
 
      04-23-2005
Hello Daniel,

"Daniel Dyer" <(E-Mail Removed)> wrote
> You don't need to do this to avoid setting a classpath, just set the
> classpath in the manifest. As somebody else mentioned, if any of your
> jars are proprietary third-party libraries (JDBC drivers for example),
> this would almost certainly be a breach of the licence.
>

Deploying Java libraries inside Oracle (Java Stored Procedures) is
a totally different story ... there is no CLASSPATH in there.

> However, if you still want to do this, I think some obfuscators have
> options to strip out all unused classes.
>

I am reviewing this option ... is there any you can refer?

Thanks in advance,
Best Regards,
Giovanni


 
Reply With Quote
 
Jacob
Guest
Posts: n/a
 
      04-23-2005
Giovanni Azua wrote:

> - examine your jar parse it to get exactly all dependencies
> - examine recursively all dependencies for dependencies
> -of course- leaving out those that come with the JRE.
> - Build a new jar containing only what's needed ...


Actually, due to dynamic invocation, the task is
impossible. An obfuscator does its job correctly
only when supplying lengthy lists of what *not*
to obfuscate (and you always miss some which makes
obfuscation really expensive to support

For 3rd-party classes you wouldn't even know.
 
Reply With Quote
 
JScoobyCed
Guest
Posts: n/a
 
      04-25-2005
Giovanni Azua wrote:
> I think a tool like this should be able to:
>
> - examine your jar parse it to get exactly all dependencies
> - examine recursively all dependencies for dependencies
> -of course- leaving out those that come with the JRE.
> - Build a new jar containing only what's needed ...
>
> If this kind of tool does not exist would you agree it should
> have a good market?
>
> Thanks in advance,
> Best Regards,
> Giovanni
>


Proguard is a free tool (obfuscator) that can do that. But due to
dynamic invocation, I would suggest the following process:
- Build a jar file of your code
- use Proguard to optimise bytecode and remove unecessary classes (make
sure to include dynamically called classes in the configuration)
- assemble all the needed jars to you final fat jar

Running a dependency/walk-through tool on third party libs is dangerous
(you can never garanty all of the really needed classes are preserved)
and often illegal

Now it's all up to you

JSC
--
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
java -cp a.jar -jar b.jar => Works on Windows, not on Debian cyberco Java 4 02-14-2006 06:27 AM
jaas.jar, jta.jar jdbc-stdext.jar missing from jdk1.5 RPM muttley Java 0 10-20-2005 02:40 PM
Differences of xercesImpl.jar, xercesImpl-J.jar, dom3-xercesImpl.jar ? Arnold Peters Java 0 01-05-2005 10:59 PM
Differences of xercesImpl.jar, xercesImpl-J.jar, dom3-xercesImpl.jar ? Arnold Peters XML 0 01-05-2005 10:59 PM
Assembling a Message from System.in (Standard Input) Rogue Chameleon Java 6 10-05-2004 08:03 PM



Advertisments