Build standalone executable

Discussion in 'Java' started by carl.manaster@gmail.com, Oct 24, 2006.

  1. Guest

    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
    , Oct 24, 2006
    #1
    1. Advertising

  2. Joe Attardi Guest

    On Oct 24, 12:20 pm, 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

    --
    Joe
    Joe Attardi, Oct 24, 2006
    #2
    1. Advertising

  3. Joe Attardi wrote:
    > On Oct 24, 12:20 pm, 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.
    Andrew Thompson, Oct 24, 2006
    #3
  4. wrote:

    > 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.


    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.


    --
    Morten
    Morten Omholt Alver, Oct 25, 2006
    #4
  5. Ian Wilson Guest

    wrote:
    > 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
    > 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.
    >


    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.

    --
    Ian.
    Ian Wilson, Oct 31, 2006
    #5
    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. Dipesh Mehta

    Standalone Perl Executable ? ? ?

    Dipesh Mehta, Sep 30, 2003, in forum: Perl
    Replies:
    3
    Views:
    4,603
  2. Peter
    Replies:
    13
    Views:
    12,231
  3. Mahesh
    Replies:
    2
    Views:
    408
    '@'.join([..join(['fred','dixon']),..join(['gmail'
    Mar 27, 2005
  4. Amit Gupta
    Replies:
    8
    Views:
    517
    BlueBird
    Apr 1, 2008
  5. epsilon
    Replies:
    6
    Views:
    1,501
    epsilon
    Jan 15, 2010
Loading...

Share This Page