jar assembling tool ...?

Discussion in 'Java' started by Malte, Apr 23, 2005.

  1. Malte

    Malte Guest

    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.
     
    Malte, Apr 23, 2005
    #1
    1. Advertising

  2. 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
     
    Giovanni Azua, Apr 23, 2005
    #2
    1. Advertising

  3. Malte

    Jacob Guest

    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?
     
    Jacob, Apr 23, 2005
    #3
  4. Malte

    Daniel Dyer Guest

    On Sat, 23 Apr 2005 13:08:27 +0100, 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 ...


    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
     
    Daniel Dyer, Apr 23, 2005
    #4
  5. Hello Malte,

    "Malte" <> 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
     
    Giovanni Azua, Apr 23, 2005
    #5
  6. Hello Jacob,

    "Jacob" <> 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
     
    Giovanni Azua, Apr 23, 2005
    #6
  7. Malte

    Marcus Guest

    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.
     
    Marcus, Apr 23, 2005
    #7
  8. Hello Daniel,

    "Daniel Dyer" <> 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
     
    Giovanni Azua, Apr 23, 2005
    #8
  9. Malte

    Jacob Guest

    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.
     
    Jacob, Apr 23, 2005
    #9
  10. Malte

    JScoobyCed Guest

    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
    --
     
    JScoobyCed, Apr 25, 2005
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rogue Chameleon
    Replies:
    6
    Views:
    354
  2. Arnold Peters
    Replies:
    0
    Views:
    598
    Arnold Peters
    Jan 5, 2005
  3. muttley
    Replies:
    0
    Views:
    2,754
    muttley
    Oct 20, 2005
  4. cyberco
    Replies:
    4
    Views:
    3,808
    Roedy Green
    Feb 14, 2006
  5. Arnold Peters
    Replies:
    0
    Views:
    681
    Arnold Peters
    Jan 5, 2005
Loading...

Share This Page