Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2006

Tip: Looking for answers? Try searching our database.

Build standalone executable

Thread view: 
carl.manaster@gmail.com - 24 Oct 2006 17:20 GMT
Hi, all,

I'm sorry if this is a silly question, but I've googled without
success.  I have a little applet that processes some numbers and plots
them; it uses classes from my own body of code and from libraries like
JFreeChart.  I want to package this up into a standalone application
that I can put on my colleague's desktop so he can try it out.  We're
both on the same OS, Windows.  I'm using Eclipse.

I have wrapped the JApplet up with a main() that creates a new JFrame,
pops the applet into it, and handles window close.  I can run from the
Eclipse environment as either an applet or an application.  It does
what I want.  I don't want to put it on a web page, just create a
standalone executable.  It does not need to be able to run across
multiple platforms; just Windows.  What are the steps to do this?  I
would like for Eclipse to figure out the dependencies and bundle
together whatever classes it needs.  No fancy icon, just something my
colleague can double-click to launch.  Thanks for any help with this.

Peace,
--Carl
Joe Attardi - 24 Oct 2006 17:34 GMT
On Oct 24, 12:20 pm, carl.manas...@gmail.com wrote:
> No fancy icon, just something my
> colleague can double-click to launch.  Thanks for any help with this.

Hey Carl,

You don't necessarily need to wrap it up in an EXE. You have two
simpler options:

(1) An executable JAR file. If you package your entire application up
in one JAR file, including all the libraries it uses, and set the
Main-Class attribute of the JAR's manifest, then double-clicking the
JAR file in Windows should bring up your app.

(2) A batch file. This will let you set your CLASSPATH then run the
app. Something like:

@echo off
set CLASSPATH=jfreechart.jar;foo.jar;bar.jar;MyApp.jar
java -classpath %CLASSPATH% com.foo.MyApp

Signature

Joe

Andrew Thompson - 24 Oct 2006 23:08 GMT
> On Oct 24, 12:20 pm, carl.manas...@gmail.com wrote:
> > No fancy icon, just something my
> > colleague can double-click to launch.  Thanks for any help with this.
....
> You don't necessarily need to wrap it up in an EXE. You have two
> simpler options:
>
> (1) An executable JAR file. If you package your entire application up
> in one JAR file, including all the libraries it uses,

Onve you have this, you might also wrap it in a JNLP
and launch it using web start (the project would not even
need a main()/Frame.

>...and set the
> Main-Class attribute of the JAR's manifest, then double-clicking the
> JAR file in Windows should bring up your app.

..but since the main/frame are already there, this also
makes sense....

(..and note that it is easy to add a fancy, or trivial,
splash image/launch icon to a web start project. )

Andrew T.
Morten Omholt Alver - 25 Oct 2006 10:52 GMT
> I have wrapped the JApplet up with a main() that creates a new JFrame,
> pops the applet into it, and handles window close.  I can run from the
[quoted text clipped - 5 lines]
> together whatever classes it needs.  No fancy icon, just something my
> colleague can double-click to launch.  Thanks for any help with this.

You can use JSmooth (http://jsmooth.sourceforge.net/) to create a
Windows .exe file after packaging your application in a jar file.
JSmooth allows you to set the application icon, and some other stuff.
The user must still have Java installed.

Signature

Morten

Ian Wilson - 31 Oct 2006 15:53 GMT
> Hi, all,
>
> I'm sorry if this is a silly question,

Don't be, it isn't.

> but I've googled without
> success.  I have a little applet that processes some numbers and plots
[quoted text clipped - 12 lines]
> together whatever classes it needs.  No fancy icon, just something my
> colleague can double-click to launch.  Thanks for any help with this.

This is a FAQ, the answers I've seen include:

1. Create an executable Jar. These can be run by double clicking and
icon on a Windows PC which has a JRE installed. It won't work without a
JRE. AFAIK this is the only deployment option supported by plain old
Eclipse. Eclipse can produce the Jar but doesn't package it in an
installer (setup-appname.exe). There are at least a dozen 3rd party
installers that will package up a Jar file for installation. The
commercial/proprietary ones seem the most fully featured. Some
installers still depend on a JRE being already installed on the target.

2. Use Java Webstart. This works well once the JRE is installed. I
suspect the whole installation process, for a brand-new Windows XP PC
without JWS/JRE preloaded, is still rather longer and more complicated
than most people would want.

3. Use an EXE wrapper. E.g. JSmooth. This can also take care of finding
a suitable JRE and downloading it as needed. Installing a JRE is still
an intrusive operation for end-users.

4. Compile to native binary. E.g. Gnu GCJ and Gnu Classpath.
http://javacompiler.mtsystems.ch/ is one packaging of GCJ. Excelsior Jet
is a commercial solution. No JRE required AIUI.

With 3 & 4 you can use a normal Windows installer to install the exe
with desktop icons etc.

As I see it, each of the above have their pros and cons, so no one
solution is right for all circumstances.

Some selection criteria (targeting Windows):
- How big is the installer bundle?
- Does the user have to work through Sun's JRE download procedure?
- Do shortcuts get installed (with icon) in Start menu & Desktop?
- Does the app get listed in Windows Control-Panel Add/Remove Programs?
- Is the running app listed under its own name in Task Manager?

For a one-off, small app, targeting a friend/colleagues PC, I'd use an
executable Jar. YMMV.

Signature

Ian.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.