Deploying a Java game on Steam

Hello,
Forgive me for asking, but I fail to find documentation related to my problem.
I’m a hobbyist game developer preparing my first release on Steam. My game has only one dependency: java JRE. Surely there is other games on the platform with such a common dependency. However I do not understand what is the preferred way to handle this dependency as of now:

  • It seems that packaging the JRE into my binaries is frowned upon by Oracle and not really a recommended practice.
  • It seems that install script will only help me on Windows, not Linux or Mac.
  • It seems that any solution that I’ve found on the web mentioning shared package may be deprecated ?

Would you please advise me on the best way to handle a JRE dependency?
Thanks a lot!

Embed the whole JRE structure in your game. This is actually what Oracle want you to do. They only take umbrage, in theory, if you change anything in the JRE distribution. (In practice they don’t give a crap but don’t tempt fate).

Cas :slight_smile:

That’s changing too. If you read the blog post I linked to in the Oracle OpenJDK thread there’s a bit about this, but also a reference to jlink coming in Java 9 that will allow for building custom runtime images of modules.

Right now, if you use OpenJDK anyway (eg. Azul has cross-platform versions) you can pull it apart however you want.

Thanks a lot to you both! That’s very reassuring :slight_smile:
I’ve found a couple of links around so I should be able to take it from here, but if you’d like to tell me your favorite tool to package a JRE with my app that would be most appreciated :slight_smile:

I use no special tools as such, I just tar up the entire directory structure, game and all, and gzip.

Cas :slight_smile:

Also relevant to this topic in case anyone missed it, Oracle now plans to ship OpenJDK builds (GPL) which will be identical to the Oracle JDK (BCL). See Java: Free At Last.

That’s what the other thread referred to earlier (Oracle OpenJDK, every 6 months) is about. Lousy title, I know! :slight_smile: Still, I find the 6-monthly releases at least as interesting as the license change, but then I never use Oracle’s releases anyway - OpenJDK on all 3 OS’s here.

The licensing change is actually hugely significant, because it means chopping up JDKs to make them smaller.
And it means finally a path to PS4 and XB1 if someone can be arsed.

Cas :slight_smile:

You have heard of this OpenJDK thing, right?! :stuck_out_tongue: It’s 99% (ish) the same code, and nothing has been stopping you from doing any of those things for years. Which means there was already a path to PS4 and XB1 with that license, by which I assume no-one could be arsed. ;D [EDIT - ignoring the mention of an open build and testing infrastructure which is interesting.]

Yeah, I’ve been using OpenJDK for years (at least on Mac and Linux, haven’t bothered with Windows yet). I think though that the main issue was there not being a credible implementation of the JDK (well, HotSpot) anywhere else without paying Oracle money. So no useful JVM on consoles, Raspberry Pi, etc.

Cas :slight_smile:

Wait a second, isn’t there some Steam feature that allows you to install dependencies? I’ve seen a game install VC redist tons of times, why not the same with the JRE?

There’s no reason to install anything, the JVM can be put in your game folder and be used from there, as an embedded runtime environment, like it’s supposed to.
Why should you f**k around with the users system by installing anything except of your game files into the steamapps folder? This only gets you esoteric bugs and then bad reviews…

I see your point. That does seem like a better idea :slight_smile:

@princec

Sorry for necroposting but I’ve read a little bit on this topic and just copying my JRE to my project seems to be the easiest way. There are a lot of different tools and I’m not sure if these might be little bit overkill. Could you maybe elaborate a little bit on how you achieved that your games is using it’s on JRE? My current unterstanding is somewhat of the following:

  1. Copy JRE into my game project folder (e.g. a folder with java8)
  2. Zip everything up (Somehow included in my build process)
  3. Tell Maven to use the included JRE

What I’m a little bit struggling with right now is how can I tell Maven to use the embedded JRE? Right now to build my game I’m using the maven-assembly-plugin along with the maven-nativedependencies-plugin to resolve native dependencies and the maven-jar-plugin.

I assume that I somehow need to tell maven to unpack that shipped JRE and use it? However is it even possible for Maven to unzip a packed JRE and tell my game to use this without using the JRE itself (Because it might require an unpacked JRE to be able to do so)?

In a few words I’m just not entirely sure how I can optimize my Maven build process to use an embedded JRE. If you could link me to a ressource or give me a hint that would be great!

What about working with the Java 9 Deployment Guide?

I just worked through an article on Modules, which is kind of important to know something about, to make this path work. Also was able to make a JLink example work. Am hoping to give this a try in the next week or so.

It is kind of a pain in that a lot seems to be done at the command line level, and the file structure needed for Modules makes Eclipse Oxygen see red. But it also seems to be what Oracle is suggesting as the way to go for distribution of a Java program as an .exe. The resulting Modular JRE included in the self-contained deployment is supposed to be smaller and faster.

We started using jlink’ed images in production a few months before Java 9 was released, they’re convenient and work great. One problem is that all dependencies must be modular. Having an Automatic-Module-Name in the manifest is not enough, all JAR files must include a module-info.class with appropriate declarations.

A relatively easy solution to this is the ModiTect plugin for Maven. It injects module-info.class in your non-modular JAR files automatically, but the module descriptors must be written by hand. It can become annoying if dependencies use reflection a lot, but it’s usually straightforward.

I’ve never looked at Maven nor gradle. Ant works for me.

Cas :slight_smile:

Thanks for the responses guys. Ill check this out. This actually sounds quite interesting since right now I’m using Java 8 and not 9, eventhough it might be worthy upgrading.

Unfortunately all of this sounds a bit tricky I hoped that it might be a little bit easier :smiley:

Indeed, don’t make life hard for yourself. Just deploy the entire embedded JRE you want, and use jsmooth to create a launcher for it.
On the Mac it’s just a zip of a .app folder with a shellscript to launch and a .plist file explaining to the system how the app is configured.
On Linux it’s just a tar.gz and a shellscript to launch.

All three methods just involve an entire JRE - the lib and bin folders specifically - and your game stuff at the root. There’s really nothing to it. Use Ant to automate it if you want but there’s not even really a need to do that.

Cas :slight_smile:

I couldn’t figure JSmooth out. Gave up and decided to give the Java 9/JLink path a go.

Migrating to Java 9 was easy. I don’t have any external jars, just Java, with Swing front end on this one.

If I can’t get the deployment to work, maybe I’ll go back to trying JSmooth again, but I’ll be asking a lot of questions here! I don’t seem to have some of the background knowledge needed to make it work.