Bundle JRE with JME app using Gradle?

Hello everybody, came here because I’m also interested in this topic. I just want to suggest that, whatever the working solution may be, it should definitely be somehow included in jME and explained in the wiki.

2 Likes

I agree this would be ideal… the entire time I was setting this up for Mythruna I was thinking the same thing.

In the end, it may be tricky. The best solution seems to depend on what tradeoffs you are willing to make and what version of Java and gradle you are trying to use. The option I went with even breaks my distZip (application plugin) customized scripts and so I have to maintain two build files just to keep it working.

I still hope that folks smarter than me can sort it out, though. I have doubts.

Some of the discussions here led to the jmonkey initializer including this in it’s gradle template.

Gradle projects created using start.jmonkeyengine.org will have gradle scripts automatically included that will bundle JREs for windows, linux and mac builds

4 Likes

This was my solution if anyone is interested: JME3 Create an exe file - doesn't work - #22 by tlf30

Edit: this solution uses gradle to build an exe launcher to run a packaged jvm to launch the app. This has several advantages, first you can specify to use the non integrated GPU on laptops, and you get an exe you can make a shortcut to and get a start menu entry in windows. This is all with a gralde submodule so it requires minimal changes to your build scripts.

1 Like

Hey this one is a really great idea!

Just tried it out and noticed that the resulting distribution is not executable, not even the single jar of my application. Did I do something wrong? However, I added one old gradle script of mine to generate a fat jar and now everything works as it should. I am thinking of proposing to add this little task of mine to the jME initializer but I don’t know where to find the repo.

Each distribution should have a bat (or sh) file. That ropes in the JRE and starts everything up.

Something like this?

#!/bin/sh
./jre/bin/java -jar ./myfatjar.jar

That looks like it, assuning you called your application myFatJar. Double clicking that should start the application

It works! Thank you. The next step should be to add the game icon.

Just in case, JavaPackager will handle all of them for you (app icon [.ico for win, .icns for mac, .png for linux], bash script generation, bundling minimal-sized JRE, additional resources, Mac-specific app directory structure, vmArgs,…)

1 Like

As pspeed says it all kindof becomes specific to what you want. For example if youre targeting a steam distribution having a file icon isn’t that important because the user never sees it

(Unless you mean a start bar icon (or mac/linux equivalent), thats always important)

as far as i remember steam adds windows pulpit game icons, so its visible there.