LibGDX Min JRE Version

When I package my game in Launch4J, I have to specify the min and max JRE versions. I’m not quite sure what to do for the minimum. I’m using LibGDX, with LibGDX’s controllers, and that’s it. I’m not using Box2d or AI.

Currently, it’s set to 1.8.0_111, which I just took from an example and I’m not sure if I should be setting it to that.

I guess I could experiment until it doesn’t work, but I figured someone might know off the top of their head. Also, if this is in the LibGDX docs somewhere, point me to that if you could. Thanks :slight_smile:

I recommend shipping the entire VM and not relying on a system JVM.

2 Likes

I recommend NOT doing that, I for one loathe having 50 different JVMs because some users are too lazy to “install java”, and god forbid the JVM shipped has a massive security flaw.
The JVM isn’t just some small library, it easily grows a simple 4KB program into over 40MB, and that adds up. Every time I see an application saying “Installing JRE” while already having the latest JVM installed my soul dies a little more.

Sadly most libraries seem to never actually specify their required Java versions for some ungodly reason. I always just use eclipse and have versions 5-8 installed and just compile and run to see if I get a version error, though only really test 6-8 anymore. If you only care about modern systems and if it works on any Java 8 version, it should (most likely) work for all Java 8 versions.

The JRE isn’t small but it can be hacked down to size if you can be bothered. In the world of games the JVM itself doesn’t amount to a lot compared to the size of assets (for modern titles of moderate budget, at least), and the guarantee of it working outweighs everything, especially when someone’s money is involved, and your time is valuable.

YMMV, but… I speak from 20 years experience of deployment in the wild.

Cas :slight_smile:

3 Likes

You obviously (and @princec also didn’t mean that) would not install the packaged JRE system-wide. You would simply unpack it into your game’s install folder and invoke it there and only there.
Given that nowadays games grow into the hundreds of Gigabytes actually when installed, adding 40MB for a simple JRE (which can also be downsized to a fraction of that), is nothing, but it is the only reliable way to know that your software will work on a target host.

1 Like

I guess I can understand both points (@KaiHH @princec) but I personally prefer not having a JVM included, and also worry about possible security bugs that won’t get updated in the included JVM. I have only ever had issues with compatibility in JVMs when the installed is actually broken (i.e. the entirety of Java 7), other than that I have never had issues with system JREs. Most of my games are not gigabytes in size, though most of my games are barely functional anyways, so I’m reluctant to ever include a JVM.

I would like to continue this discussion though clearly this is not the right thread

It is a useful discussion to have - please feel free to create another thread!

1 Like

You guys are smart. I couldn’t figure out how to package the JRE with it, so I left it as “if the user doesn’t have java prompt the download”. Everything I tried with Launch4J wouldn’t launch the game correctly on a computer that didn’t have java.

Users really shouldn’t have to worry about installing java nowadays (or even have to know what it is), therefore packaging is really the best way to go.

For Launch4j, just put the jdk or jre in a folder, for example if we name this folder “jdk11” (i.e this folder contains the bin, lib, etc folders of the jre/jdk), then the Launch4j JRE tab should look like:

Then we simply place the “jdk11” folder next to the generated launch4j exe file and it will pick it up when running your application.

2 Likes

I’ve used Packr that comes with its own JRE packaging optimization and it worked very well for me. You can even take the packaged and optimized JRE (I’ve used Java 8) and remove more, not needed libraries and packages from it to get the size down. This may be a bit of trail and error but you only have to do it once for every system you want to publish your game for.

For example, for my project it was possible to remove all the awt and swing packages of the different vendors from the rt.jar but also a lot of other libs.

2 Likes