Combine all the jar into one JAR

View: New views
5 Messages — Rating Filter:   Alert me  

Combine all the jar into one JAR

by EricMacau :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

Is there any function in NetBeans 6.1 to combine all the JAR library
into one JAR?

Best regardrs,
Eric

Re: Combine all the jar into one JAR

by Richard Ivarson-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Eric Chow wrote:
> Hello,
>
> Is there any function in NetBeans 6.1 to combine all the JAR library
> into one JAR?

Interesting question: unfortunately I don't know.

Manually, you could unpack all your JARs to the same folder, and than JAR/ZIP
the contained files to one JAR file.

But of course this is not comparable to NB's helpful automatic JAR file
generation...

-Richard


Re: Re: Combine all the jar into one JAR

by Fabrizio Giudici :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Remember that merging JARs can be explicitly prohibited by some  
licenses. For instance, I believe that this practice is prohibited by  
GPL and LGPL.

On May 8, 2008, at 6:41 , Richard Ivarson wrote:

> Eric Chow wrote:
>> Hello,
>> Is there any function in NetBeans 6.1 to combine all the JAR library
>> into one JAR?
>
> Interesting question: unfortunately I don't know.
>
> Manually, you could unpack all your JARs to the same folder, and  
> than JAR/ZIP the contained files to one JAR file.
>
> But of course this is not comparable to NB's helpful automatic JAR  
> file generation...
>
> -Richard
>
>

--
Fabrizio Giudici, Ph.D. - Java Architect, Project Manager
Tidalwave s.a.s. - "We make Java work. Everywhere."
weblogs.java.net/blog/fabriziogiudici - www.tidalwave.it/blog
Fabrizio.Giudici@... - mobile: +39 348.150.6941



Re: Combine all the jar into one JAR

by Richard Ivarson-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Fabrizio Giudici schrieb:
> Remember that merging JARs can be explicitly prohibited by some
> licenses. For instance, I believe that this practice is prohibited by
> GPL and LGPL.

OK.
However for my own library JARs, which I share between several projects, I'd
wish to be able to make NB merge them into one JAR. Is this possible, somehow?

-Richard


Re: Re: Combine all the jar into one JAR

by Giampaolo Melis :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

To achieve a sort of automation you can override the -post-dist target
in the project build.xml file.
For example:

<tempfile property="unpack.temp.dir" prefix="unpack" suffix=""/>

<target name="-post-dist" depends="unpack-jars, merge-jars"/>

<target name="unpack-jars">
        <mkdir dir="${unpack.temp.dir}"/>
        <unzip src="${jar1}" dest="${unpack.temp.dir}"/>
        <unzip src="${jar2}" dest="${unpack.temp.dir}"/>
        <unzip src="${jar3}" dest="${unpack.temp.dir}"/>
        ...
</target>

<target name="merge-jars">
        <jar jarfile="${my.big.jar}">
                <zipfileset dir="${unpack.temp.dir}"/>
        </jar>
        <delete dir="${unpack.temp.dir}" quiet="true" includeEmptyDirs="true"/>
</target>

Giampaolo

On Thu, May 8, 2008 at 5:09 PM, Richard Ivarson <RiIvarson@...> wrote:

> Fabrizio Giudici schrieb:
>>
>> Remember that merging JARs can be explicitly prohibited by some licenses.
>> For instance, I believe that this practice is prohibited by GPL and LGPL.
>
> OK.
> However for my own library JARs, which I share between several projects, I'd
> wish to be able to make NB merge them into one JAR. Is this possible,
> somehow?
>
> -Richard
>
>