Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to turn a Java application into a standalone package that runs "out of the box"? The end user should not be required to install any Java JRE, nor should the installer contain a JRE and install it for the user.

The final distribution should contain a native executable (hopefully one for each of Windows, Mac and Linux) along with the regular data files and any extra JARs if needed. I'm not looking for a "one file" solution specifically -- I'd actually like data files to be unobfuscated.

How can this be done?

share|improve this question
up vote 7 down vote accepted

The main point is that the end user should not be required to install any Java JRE, nor should the installer contain a JRE and install it for the user

You can use Java source/bytecode to machine code compilers. There are Excelsior JET for Windows and Linux (requires license) and GNU Compiler for Java which is old.

If it's ok to contain Java with your game without installing it, then you can probably package Java Runtime with your game and use a start script to set JAVA_HOME to your JRT location prior to launching the game.

EDIT: (comment response) Using the second option, you will still need different builds for different platforms using the appropriate Java runtime for that platform.

share|improve this answer
If your game is non-commercial, you can get a free Excelsior JET license. – Dmitry Leskov May 12 '13 at 6:53
The second option sounds good, but if I package my Windows JRE, is it crossplatform? Similarly with Excelsior, would I need to run such compilers on the three different OSes? – leokhorn May 15 '13 at 7:42
You would need to bundle that platforms JRE with each release, but essentially it will remain cross platforms. – Derek May 15 '13 at 19:26
@leokhorn At some point, there has to be native code. Either you have to compile to native code, or you have to run on a native VM. There is no plan C. – Adrian May 16 '13 at 19:28

For Mac, see the Oracle documentation for packaging a Java app for Mac. They've set up Java 7 so that you can bundle the runtime into an application bundle containing your jar files (.app is a folder treated as executable really), which is required for distribution on the Mac App Store. Basically, the .app bundle does mostly the same as what Eren's JAVA_HOME answer suggests, but is packaged as a "native" Mac app.

For distributing without the Mac App Store, you can get away with not signing the app, telling your Mountain Lion users that they can get around Gatekeeper by right-clicking (or ctrl+click) on your app and clicking on "Open" when they first open the app. This will still warn them that the app is not signed, but it will allow them to open it anyway, and then allow them to double click on the app for subsequent opens.

(side note: you could also get away with Linux-style marking of shell scripts as executable and then construct a .app bundle around that. NetBeans does this on Mac and Linux, though without a bundled JRE/JDK)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.