[PJUG Javamail] Packaging Java Applications

Kent Spaulding kent at iotabits.com
Tue Aug 11 22:23:09 UTC 2009


Ant is one means - if all you care about is the executable then use  
eclipse's 'Runnable Jar' feature.

For you project, click File|Export.. and in the treeview select as in  
the attached screenshot.  It will allow you choose what to bundle.

If your version of eclipse doesn't do this, there is a plugin called  
FatJar that will (which is where this feature came from)

The resulting jar file is run as:

java -jar myjar.jar <arguments>

--Kent

-------------- next part --------------
A non-text attachment was scrubbed...
Name: Picture 1.png
Type: image/png
Size: 59368 bytes
Desc: not available
URL: <http://javac.com/pipermail/javamail/attachments/20090811/b0da8b9a/attachment-0002.png>
-------------- next part --------------

On Aug 11, 2009, at 2:48 PM, Aaron Getz wrote:

> I agree with Zack,
>   If you don't mind the Eclipse dependency then you can right click  
> on the project and then choose export->General->Archive File.  That  
> will export your project into a zipped archive that a user can then  
> take and bring into their own Eclipse workspace.
>
>   If you have been using ant and you don't want an Eclipse  
> dependency then you should use the Ant jar task to create a jar file  
> of your compiled class files and do like Zack suggests, zip  
> everything else up that you deem important and distribute it that way.
>
> Ant also has zip and tar tasks for distribution purposes.
>
> Aaron
>
> On Tue, Aug 11, 2009 at 2:41 PM, Zack Radick <zack at crc-corp.com>  
> wrote:
> Dan,
> If you are using Ant for your build, check the Ant docs regarding the
> "Jar" and "Manifest" core tasks
> (http://ant.apache.org/manual/index.html).  A manifest file is meta
> information for the jar to declare dependencies and other packaging
> information, such as the main class to run (so that a user can double
> click the jar to run it or execute it with a "java -jar myjar.jar"
> command).  Jar files do not typically include other jar files that
> they depend on.  These are usually included in a library directory,
> so you probably want to package your end product as a zip which
> includes the executable jar, a directory of it's library files, and
> any other runtime stuff you feel may be needed (docs?).
> --Zack
>
> At 02:32 PM 8/11/2009, Dan Colish wrote:
> >Well, I'm just trying to package it so a user can clone my git repo  
> and
> >easily build the source. This is not an eclipse plugin. It's just a
> >standard cli application. I'd like to include the dependency since  
> its
> >licensed to allow that. FYI, the dependency is joda-time.
> >
> >Does packaging into a jar allow this? I'm a little confused by the  
> end
> >purpose of a jar. Also, if I do this outside of eclipse even better.
> >I've looked it ant, and it's what I am currently using to do the  
> builds.
> >
> >--
> >--Dan
> >
> >
> >On Tue, Aug 11, 2009 at 02:18:29PM -0700, Aaron Getz wrote:
> > > Hey Dan,
> > >   I guess it depends on what you are initially trying to package  
> up.  Is
> > > this an Eclipse plugin?  If so then you can just highlight the  
> project and
> > > right click and then choose to export it and the PDE builder of
> > Eclipse will
> > > handle the rest.
> > >
> > >   In the case of a Eclipse plugin you would include the 3rd party
> > lib in the
> > > jar file you create.
> > >
> > >   If you are just looking to create a jar file that is your  
> source code and
> > > then the consumer of your jar file is responsible for getting the
> > > dependencies needed for using your jar file.  If you want to  
> include the
> > > jars along with your jar file then you can classpath the jars in  
> your
> > > manifest file and make sure the user of your jar puts them in  
> the path you
> > > specified or they can create their own classpath.
> > >
> > > Here is a good tutorial on jar files from Sun
> > > http://java.sun.com/docs/books/tutorial/deployment/jar/
> > >
> > > And here is another document on setting the classpath
> > > http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/ 
> classpath.html
> > >
> > > I hope that helps out.
> > >
> > > Aaron
> > >
> > > On Tue, Aug 11, 2009 at 2:09 PM, Dan Colish  
> <dan at unencrypted.org> wrote:
> > >
> > > > So I need to packaage up some source code in an Eclipse  
> project for
> > > > sharing. Normally, I'd just point someone to my git repo, but  
> I have
> > > > included external libraries in my project. I'm now having some  
> trouble
> > > > figuring out how to deal with this. Do I include that jar too?  
> If so how
> > > > does the person run that without extensive setup? Isn't there  
> a simple
> > > > way to include libraries like in C/C++ where I have an include  
> and a
> > > > compat dir, then just link against them in my makefile? I'm  
> new to Java
> > > > packaging so any help is appreciated.
> > > >
> > > > --
> > > > --Dan
> > > > _______________________________________________
> > > > Web Site - http://www.pjug.org/
> > > > Javamail mailing list
> > > > Javamail at pjug.org
> > > > http://www.pjug.org/mailman/listinfo/javamail
> > > >
> >_______________________________________________
> >Web Site - http://www.pjug.org/
> >Javamail mailing list
> >Javamail at pjug.org
> >http://www.pjug.org/mailman/listinfo/javamail
>
>
> _______________________________________________
> Web Site - http://www.pjug.org/
> Javamail mailing list
> Javamail at pjug.org
> http://www.pjug.org/mailman/listinfo/javamail
>
> _______________________________________________
> Web Site - http://www.pjug.org/
> Javamail mailing list
> Javamail at pjug.org
> http://www.pjug.org/mailman/listinfo/javamail



More information about the Javamail mailing list