Deployment: embedding Java VM in a game

Hey happy people @ JGO!

I’ve been looking around a bit for a good answer to this question, but I could not find it. I’d like to follow the prophesy of Cas, whom I quote completely out of context:

[quote]we don’t care! We just want stuff to work.
[/quote]
Edit: make sure to listen to this to get in the right mood.

I also want stuff to work, and I don’t mind if things are theoretically pure. Now I’m looking for a good way (i.e. one that “works”) to deploy a Java game (using LWJGL) as a Windows executable that works whether or not the user has installed a JVM. In other words, I’d like to embed a JVM into an executable, but I’m not sure how to do this.

This is what I do know:

The Oracle JRE
According to the Oracle JRE readme it is perfectly normal to distribute the JRE alongside with your application:

[quote]The Java™ Platform, Standard Edition Runtime Environment (JRE™), excluding the JavaFX™ runtime, is intended for software developers and vendors to redistribute with their applications.
[/quote]
I presume this is also true when I embed the JRE inside my executable. (after all, it’s not much different from distributing it in a ZIP file)

How to make it small
Also in the JRE readme is a list of files that can be excluded. When I strip away most of these files, the JRE is still (compressed) 24MB. While that’s not a huge problem, I’d like to reduce it in size further. One thing I’m thinking of is to keep on stripping stuff out until my game no longer works… How would you guys do this?

Here’s what I found so far:

  • Remove the optional files listed in the JRE readme (make sure to also remove the files that are used for the browser plugins).
  • Compress the rt.jar runtime library as described in this Oracle blog post.
  • Use an alternative JVM that has a small footprint, e.g. JamVM. As far as I understand, this may have severe performance implications however.

The embedding process
What tools can be used to embed a JRE? I know that launch4j has an “embed JRE” function, but I’m not sure what else is out there. What tools or approaches are best when embedding a JRE?

Thanks!

I just copy the complete JRE folder (plus server VM) into my game folder. Stripping anything apart from the listed files breaks the license agreement.
I don’t embed the JRE but let the exe launch the game with the private JRE.

(@65k - That’s what is generally meant by “embedding” the JRE)

launch4j and jsmooth are well known contenders for running Java apps with private JREs. I build my own launcher exes.

There will be a little turmoil ahead as Mac OS transitions to OpenJDK7 and I’ll have to figure out the foibles of deploying that (it’s not going to be straightforward - the games have to remain backwards compatible with OSX 10.5.8 and above as well, and LWJGL still doesn’t work with OpenJDK7 on the Mac yet).

For Linux I will be shifting to embedded private JREs as well, if only for parity’s sake. I strongly dislike the concept of systemwide Java. Fortunately with the recent spate of stunningly powerful malware using systemwide Java as the vector it may finally be coming to a head.

Cas :slight_smile: