I have a java web start game which people with Java happily play but many folks don't have Java and don't want to install Java. I tried zipping the jar and including java.exe in the zip, then I had a small windows bat file that calls the java.exe to run the jar. It worked fine on my machine but then I already have Java. It didn't work on PC's with no Java or an out of date Java.

Jsmooth - will this just run the java.exe program in my zip file? I want to avoid the program even mentioning to the user that it's running Java. The people running my program are putting it into arcade machines and obviously they just want it to run rather than show popups saying that your Java needs updating. Is it easy to use?

IzPack - same questions as above really.

C++ - I program in many languages but unfortunately C++ isn't one of them. Is there an example somewhere of how to do this? Was this how you put your Revenge of the Titans onto steam? Did you produce a blog/txt/post of how you did this and whether it was worth the effort. Obviously my little program isn't as flash as yours but it can be quite addictive and people seem to enjoy playing it so it would be nice to make a few pennies from the effort.

I remind you that you can use some options of Java Web Start to hide some elements so that they never see it requires Java. You can then provide the JRE and use Java Web Start, maybe look at the "-import" option. IzPack has no automatic update but if you want to use it, you can look at some free softwares using it, for example Art Of Illusion.

You can also use Launch4j to wrap a runnable jar file into a Windows executable. Launch4j has support for embedding a JRE.

Only including java.exe will not work, by the way, since the java runtime environment requires many other files to function. Take a look at the JRE installation on your computer (e.g. c:\program files\java\jre7 or something), it will be over 100MB in size. You van reduce the size of the Oracle JRE (which is by the way perfectly legal to redistribute along with your app) by leaving out some files and doing other tricks. There's a good answer on StackOverflow on how to do this. Still, expect a somewhat sizeable installation file, although that is hardly a problem these days.

Personally I use Excelsior JET, that integrates its own virtual machine into the compiled executable, but that is somewhat expensive for indie developers (I got it in a charity deal). I like this one because it lets me reduce the size of the resulting executable further than most other approaches (say to under 10MB including runtime), and its pretty easy to use and maintain.

I have only tried the evaluation version of Excelsior JET, it works. But the performance of my application becomes a lot worse , even with all the optimization options selected. I am not sure whether it is because I was using the trial version or I chose the wrong optimization option.

I am not sure whether it is because I was using the trial version or I chose the wrong optimization option.

Did you run the application after you finished compiling? Because the test run during the compilation wizard is slowed down a lot (because of profiling stuff happening on the background). But other than that I did not notice slowdowns for the things I compiled so far.

None want to see popups appearing telling them to download the latest Java or asking whether they really want to run the program

Many actively don't want to instal Java because of perceived security issues etc

I guess they'd prefer an exe if they had the choice - I know this rules out Linux but I guess they can run the standard jar.

PS can anyone PM me on how to get the youtube video appearing? (I tried help and half a dozen random formats)

Lets back up for a moment. Launch4j (suggested earlier) has all of that, you don't need to play around with NSIS scripts, write a custom C++ stub or AOT compile your application. With Launch4j you can configure such that it will use either the local JRE (if it is found) or the packaged JRE.

You don't need to write a C++ stub, albeit it would be incredibly easy and there are probably tons of libraries that allow you to do it more cleanly.

Did you run the application after you finished compiling? Because the test run during the compilation wizard is slowed down a lot (because of profiling stuff happening on the background). But other than that I did not notice slowdowns for the things I compiled so far.

Yes, the application was run when everything is finished. The exe version takes twice amount of cpu usage for the same frame rate. I have uploaded my app here, I am really curious to see if it makes a difference on your side

Lets back up for a moment. Launch4j (suggested earlier) has all of that, you don't need to play around with NSIS scripts, write a custom C++ stub or AOT compile your application. With Launch4j you can configure such that it will use either the local JRE (if it is found) or the packaged JRE.

You don't need to write a C++ stub, albeit it would be incredibly easy and there are probably tons of libraries that allow you to do it more cleanly.

An advantage to writing a C++ stub is that under processes you will see your games name instead of javaw.exe however this doesn't really make a difference to most users. Another might be that you could trim the JVM a little more when using a C++ stub because you don't need the JVM .exe's with a C++ stub and JNI. However I've never tried to slim down a JVM and package it with an .exe using Launch4j.

Lets back up for a moment. Launch4j (suggested earlier) has all of that, you don't need to play around with NSIS scripts, write a custom C++ stub or AOT compile your application. With Launch4j you can configure such that it will use either the local JRE (if it is found) or the packaged JRE.

You don't need to write a C++ stub, albeit it would be incredibly easy and there are probably tons of libraries that allow you to do it more cleanly.

An advantage to writing a C++ stub is that under processes you will see your games name instead of javaw.exe however this doesn't really make a difference to most users. Another might be that you could trim the JVM a little more when using a C++ stub because you don't need the JVM .exe's with a C++ stub and JNI. However I've never tried to slim down a JVM and package it with an .exe using Launch4j.

However, relative to the all your dependencies, java's exe stub is probably negligent in size. Also launch4j does allow you to customize the process name.(I have to write this in brackets because currently 90% of my post consists of quotes.)

I'd definitely also recommend launch4j for Windows packages. A single fat jar isn't a requirement, your project can have any structure, and your process can be launched with custom names, not java.exe.

I've also used NSIS for installers, which was also very nice.

I've also heard rumors that the JavaFX native packaging works for all Java apps, not just JavaFX ones (another linky). If so, that's a nice option because it creates native bundles for Windows, OS X and Linux.

I'm sorry for the late reply but there's a lot of new stuff here and none of it is obvious to me. I have so far tried :

C++ route but just became rather lost and frustrated. I also couldn't see how it would work on machines without java installed.

Excelsior JET but the licensing doesn't suit me and I was hoping for a free solution

Launch4J looks promosing and it seems to have everything I want but I'm currently stuck trying to include a jre in the build. Any ideas?

It seems a shame that there isn't a standard option in Java to just produce an exe (if windows). I know the golden ideal was to have safe code that could be run anywhere but these days I get more warnings trying to run my own jar files than I do running a random exe of the web. Users also seem more comfortable running exe's. Weird.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org