Package Runtime with Jar File for Distribution in Steam

Follow the Steps below to deploy your .jar application with an Bundled JRE runtime. I’m doing this so I can deploy on Steam as an .exe application

File > New Project > JME3 > Basic Game (with Ant) > Project Name : Basic Game

Clean and Build

Download Wix

Path variable
jpackage tool location:
C:\Program Files\Java\jdk-17\bin

I change directory so the file is created in a known place
cd C:\Users\redacted\Downloads\packager_MyGame\dist

Run this to create the file
jpackage --input C:\Users\redacted\Downloads\packager_MyGame\dist --main-jar MyGame.jar

Run this to create the file. But relative path (.)
jpackage --input .\ –main-jar MyGame.jar

Debugging Notes:

Process to stop:
Installer of Main (The program)
Stop this process so you don’t have to log off windows in order to stop the process. This is helpful to delete the .exe in order to re-do it.

VERY IMPORTANT
If you program is called Main.jar/Main.exe go to Control Panel > Programs and Features in order to uninstall.
If you go to Program Files\Main and just delete the folder. Windows will not know the program is uninstalled and you won’t be able to run the installer again. It will silently fail. And you might have to go and edit the Registry. (sad emoji)

References:

Oracle JPackage tutorial

Below is a similar tool. I helps reading the wiki so you get familiar with the terminology of this process.

References to Avoid:

These assume you are creating an application which has JavaFX integrated. Also they are about building from ant tasks. Which is not needed for a first time use.

Broken Steps in JMonkey:

JMonkey > Right Click Project > Application > Desktop
[True] Create Windows 64bit Application
[True] Bundle JRE with Applications

JMonkey > Right Click Project > Properties > Build > Deployment > Enable Native Packing Actions in Project Menu
JMonkey > Right Click Project > Package As

I believe the steps do not work because JPackage was introduced in Java 14 and not in Java 11.

5 Likes

Could you write a wiki page for this and submit a pr?

1 Like

Was able to run the game from steam.

jpackage --type app-image --input “InputFolder” --name MyGame --main-jar MyGame.jar

Let me break the command below:
Create an image.
–type app-image

Do not create and .exe or msi.

In the command line change to the active directory where your jar is located then create a folder called “InputFolder” or any other name. Use it here: --input “InputFolder”. If you don’t specify the input folder this way the packaging process will create recursive folders which are a bit hard to remove.

Zip your file with this structure:
Mygame.zip
-----MyGame.exe

Avoid this file structure:
MyGame.zip
----MyGame (folder)
----------MyGame.exe
Notice the MyGame folder should not be there.

In steam set Current Install folder to “MyGame”.

Launch Options:
MyGame.exe
Launch Type: Default

Proof:

The command line in the picture shows that java is not linked to the Path variable. Just like a user WITHOUT java JRE installed.

The blue button shows STOP because it’s running INSIDE Steam.

I’m able to play with keyboard, mouse and gamepad.

Happy coding. :slightly_smiling_face:

4 Likes

Commands for Ubuntu Linux:

This is the folder location where you placed the file to be packaged"/home/MyName/Downloads/DemoDay/20Sep2024/"

So change directory to it by typing:
cd “$HOME/Downloads/DemoDay/20Sep2024”

Run the package command:
jpackage --type app-image --input “InputFolder” --name MyGame --main-jar MyGame.jar

Read my previous comments about the InputFolder.

Below is where the launcher is located once you package the app:

Launcher:
/home/MyName/Downloads/DemoDay/20Sep2024/MyGame/bin/MyGame