Packaging JRE + java app + other jar's into an exe?

Discussion in 'Programming & Software Development' started by 0O0, Sep 21, 2006.

  1. 0O0

    0O0 Member

    Joined:
    Oct 24, 2005
    Messages:
    76
    Hi Everyone,

    I've been relentlessly searching for a freeware or open source solution to packaging a small java app i've written with a some required jar's and a suitable jre into an windows executable.

    I've found applications that make executables out of jars and i've also found applications that include the JRE as well, but the ones that include the JRE are usually commercial products that cost. Is there a half decent open source solution out there? I dont mind sacrificing useability during the configuration stage but the i'd like the final product to put together one exe if possible.

    To help with any suggestions, my application is a single class application with one import for another jar file.

    Thanks.
     
  2. mordy

    mordy Member

    Joined:
    Aug 30, 2001
    Messages:
    5,100
    Location:
    melb
    I know eclipse uses an exe wrapper. On most windows machines you can just double click the .jar file and it executes like an exe, so its not absolutely necessary to package an exe file

    Alternatively you can import ur project to j# and get a .NET executable (but you need the .net framework installed, so you cant win.
     
  3. xsive

    xsive Member

    Joined:
    Jun 29, 2001
    Messages:
    4,335
    Download a C compiler and build your own wrapper that just invokes Java :)
     
  4. jboles

    jboles Member

    Joined:
    Jun 19, 2004
    Messages:
    2,408
    Location:
    Sydney NSW / Seattle USA
    No need, just grab JLauncher and use Resource Hacker to set your own command line and application icon :)

    Works great, and very easy too. No need to rebuild the exe whenever your jars change.
     
  5. scruff

    scruff RIP

    Joined:
    Jun 14, 2003
    Messages:
    3,442
    Location:
    Melbourne
    If your target platform is Windows, you could use the Java->J# conversion tool (Maybe it's Java->C# in the new one?) and then have a .net executable...

    J# includes all the java libraries (except maybe swing - but you can get third party stuff that does that).

    Not exactally what you were after, I know, but could be an idea if you wanted to get rid of the JRE requirement.
     
  6. xsive

    xsive Member

    Joined:
    Jun 29, 2001
    Messages:
    4,335
    ..and introduce a .net requirement :rolleyes:
     
  7. moogie

    moogie Member

    Joined:
    Jun 27, 2001
    Messages:
    193
    if you are not using Swing or AWT then you can make a native win32 execuatble using gcc.

    or if you want a gui then use SWT... it will compile into an exe as well.
     
  8. scruff

    scruff RIP

    Joined:
    Jun 14, 2003
    Messages:
    3,442
    Location:
    Melbourne
    Hey. Don't roll your eyes at me.

    You'll find that more people have the .net distributable than the JRE. The whole "comes with windows update" thing tends to help the numbers. In terms of releasing a product that has a framework requirement, if you're releasing for windows then you are better off having a .net requirement than a JRE requirement. End of story.
     
  9. OP
    OP
    0O0

    0O0 Member

    Joined:
    Oct 24, 2005
    Messages:
    76
    Yeah I thought about this before I realised there were tools available that can do it for me! This doesnt solve the issue of dependency on a JRE being available on the machine.

    .NET is not really an option either as it does introduce the .net framework requirement.

    I've seen some commercial solutions which package a jre and the app jars all into one setup package, so as the application installs along with a jre.

    Its ok guys, ill talk my admins into allowing me to install the jre
     
  10. mordy

    mordy Member

    Joined:
    Aug 30, 2001
    Messages:
    5,100
    Location:
    melb
    i dont think that ppl find a jre as a huge issue these days.. remember over 20% of all code written these days is in java, so its pretty likely that they will have it installed.
     
  11. xsive

    xsive Member

    Joined:
    Jun 29, 2001
    Messages:
    4,335
    I'm confused. Why did you choose to develop in an interpreted language like java if having a virtual machine is an unreasonable requirement for your users?
     
  12. OP
    OP
    0O0

    0O0 Member

    Joined:
    Oct 24, 2005
    Messages:
    76
    I dont mind if there is a requirement for a virtual machine for a good reason, in this case the command line application I developed needed to be multiplatform, it had to run on AIX, OS/400 and Windows. .NET has the burden and restriction of a virtual machine without the portability of java.
     
  13. xsive

    xsive Member

    Joined:
    Jun 29, 2001
    Messages:
    4,335
    In that case I'm still confused. How can you expect native code *and* mutiplatform? Something has to give somewhere. Why don't you clear up what the base systems you're targetting are running and then figure out how best to solve the problem? If Java needs to be installed with your application then you can package them both together with some custom scripts that handle everything. If it turns out that all systems have at least version X.XX of some JVM then you can test develop against that and just ship your application together with a script that invokes java.

    Problem solved. No need for .exes or any other messiness. :)

    EDIT: if the JVM is a problematic for whatever reason (maybe you're doing some large numbercrunching) use straight C and ship precompiled code using something like a universal binary approach.
     
    Last edited: Oct 1, 2006
  14. scruff

    scruff RIP

    Joined:
    Jun 14, 2003
    Messages:
    3,442
    Location:
    Melbourne
    I dont think the OP was too concerned about the JRE - he just wanted to know how to stick it in a single exe to make it nice from the end user's point of view.

    It's alot easier for the end user to type

    myprogram.exe MyInputFile.txt

    from the command line than try to get them to do like

    java myprogram -classpath=c:\progra~1\sun\jre2.1.2.181.1.23.1\bin;someotherpath -random -other -options -blah < MyInputFile.txt


    or whatever.

    edit: actually reading the posts makes me believe that a sys admin wouldn't install the JRE on computers, which is why it needed bundling.
     
    Last edited: Oct 1, 2006
  15. xsive

    xsive Member

    Joined:
    Jun 29, 2001
    Messages:
    4,335
    Sounds like a script that behaves like an .exe is the go then.
     
  16. Techneon

    Techneon Member

    Joined:
    Jan 28, 2002
    Messages:
    1,074
    Location:
    Hobart || Brisbane
    Although not eliminating the whole JRE requirement, why not just put it all into a single jar file, which I am led to believe can be used to package the stuff anyway (including command line arg's so users can just double click it)?
     
  17. OP
    OP
    0O0

    0O0 Member

    Joined:
    Oct 24, 2005
    Messages:
    76
    Sorry for not replying for a while, I was about to restate my requirements in this post but I think qwijibo has answered my question, thanks very much for the guidance, I think I will be using the approach you have prescribed.
     
  18. K.I.L.E.R

    K.I.L.E.R Member

    Joined:
    Feb 10, 2002
    Messages:
    2,209
    Location:
    Melbourne, St Albans
  19. GulfWarSyndrome

    GulfWarSyndrome Member

    Joined:
    May 22, 2006
    Messages:
    40
    WinRAR isn't exactly free, but could a self extracting RAR do the job?

    Then you can have one single exe, get it to unpack everything, start the setup of the JRE, make shortcuts in start menu/desktop etc.

    It just seems like the simplest solution to me.
     
  20. magoon

    magoon (Banned or Deleted)

    Joined:
    Mar 23, 2006
    Messages:
    244
    I've never used it myself but I was reading a book not long ago that mentioned this:

    http://nsis.sourceforge.net

    Looks like it gives you the sexy installer instead of all this technical stuff.
     

Share This Page