Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (804)
Games in Android Showcase (239)
games submitted by our members
Games in WIP (868)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Professional looking games: bundling JREs and making native executables  (Read 6100 times)
0 Members and 1 Guest are viewing this topic.
Offline theagentd
« Posted 2015-04-22 14:58:29 »

Hello, everyone.

This article is about making your game look more professional to the average user.

It can't be denied that there is a certain stigma around Java for use in games. Working on We Shall Wake, both me and other members have encountered people refusing to help or talk with us because we're using Java. I've even written blog posts about why our choice is a good one, but obviously it doesn't help. Obviously, the average gamer doesn't know exactly *why* Java is bad for games, but if they know a game is made with Java and anything at all goes wrong, some people are sadly likely to blame it on Java, and these people are loud.

There are some obvious giveaways for games made in Java. The requirement of a JRE and starting the game using an executable .jar files are both dead giveaways that the game is made in Java, and most importantly they both depend on the player's computer. Being unable to start a game because Java isn't installed without a proper error message, or not being able to start it because the Java HOME variable isn't set properly will cost you quite a few players. More importantly, players shouldn't have to even care that your game is made in Java, and they definitely shouldn't have to install separate programs. In addition, many players are not used to .jar files, bat files and other formats often used to launch Java, so we want to give the player an executable file that they are familiar with. We also want these files to have the icons we specify. Thirdly, we don't want the game to open up with an ugly console/terminal window.

One option is to create an installer which automatically installs a JRE on the client computer and then installs the game. There are many freeware programs that allow the player to create installers. Personally I'm heavily against installers in the first place since the game installation file is just a glorified compressed folder with automatic extraction, and once installed many games are hard to uninstall and may leave files in weird folders all over your computer. I prefer my games portable and confined to a single folder, so an installer is out of the question.

To ease in development, the native executable should not need to be updated for each new build. Preferably it should simply launch the game's executable .jar file for you so the .jar file can be easily updated without having to remake the native executable files. As a bonus goal, the game should pop up as <GameName>.<native extension> in the task manager instead of javaw.<native extension>.

Summary of goals:
1. Being able to run the game without an installed JRE.
2. Being able to run the game without the JAVA_HOME environment variable.
3. No console/terminal window should pop up when the game is started.
4. The game should be started with native executable files on Windows, Linux and OSX.
5. The executables should have custom icons.
6. The native executables should not need to be regenerated when the game is updated.
7. (Bonus): The game should be listed in the task manager by its name instead of javaw.

The goals are achieved by:
1. Bundling a JRE with the game.
2. Directly specifying the relative path to the bundled JRE instead of relying on the environment variable.
3. Using a program to generate OS-specific executables that supports this.
4. Using a program to generate OS-specific executables that supports this.
5. Using a program to generate OS-specific executables that supports this.
6. Having the executables simply launch an OS-independent .jar file that can be updated independently of the native executables.
7. Renaming the bundled JRE's executable javaw file to the game's name.

Getting JREs for all operating systems and architectures

JREs for all operating systems can be found on Java's website (DUH). From there on, go to the JRE download page and download the .tar.gz version of the JRE you're interested in. .tar.gz files can be opened using for example WinRAR, but at least using Chrome the file is somehow renamed to .gz only when downloaded, making it impossible to see the contents of the file. In this case, manually changing the extension to ".tar.gz" solves the problem. Once you have the file opened, it's simply a matter of extracting the jar to you a folder and you have a portable JRE. The javaw executable is located in the bin/ folder. It's also possible to get server JREs for 64-bit architectures.


Generating an executable for Windows is easy. To generate a .exe file, we simply use Launch4j which supports everything we need except the bonus goal.

1. Download and install =

2. Launch Launch4j. Tongue

3. Enter the path to your game's executable .jar file. Note that this should path is relative to the .exe file you'll generate.

4. Check "Don't wrap the jar, launch only" so that the .jar file can be updated or replaced later without having to regenerate the .exe file.

5. Specify your .ico icon for the .exe file (link to online .ico converter).

6. Head to the JRE tab and enter the relative path to the bundled JRE. Assuming the bundled JRE is in a folder called jre\ in the same folder as the .exe file, this is simply "jre\".

7. Save the configuration because Launch4j hates you if you don't.

8. Generate a .exe file.

9. Profit!

Note: Since Launch4j does not allow you to specify the javaw.exe file in the JRE manually, you can't rename it to the game's name, so Launch4j does not fulfill the bonus goal. Most likely this could be worked around somehow. Suggestions are welcome!



 - Shell script file without an extension for launching? Should be able to launch bundled JRE instead.
 - .desktop entry? Goes against my hate for installers?
 - Other way of setting icon directly of the executable file?


 - .app package for easy "installation"?
 - Would your average OSX user know what to do with a file the same as for Linux? Not sure what the standard is.

There's an ongoing thread at here for people interested in helping out with expanding the Linux and OSX sections.

Pages: [1]
  ignore  |  Print  

Riven (581 views)
2019-09-04 15:33:17

hadezbladez (5510 views)
2018-11-16 13:46:03

hadezbladez (2402 views)
2018-11-16 13:41:33

hadezbladez (5772 views)
2018-11-16 13:35:35

hadezbladez (1223 views)
2018-11-16 13:32:03

EgonOlsen (4661 views)
2018-06-10 19:43:48

EgonOlsen (5682 views)
2018-06-10 19:43:44

EgonOlsen (3198 views)
2018-06-10 19:43:20

DesertCoockie (4095 views)
2018-05-13 18:23:11

nelsongames (5115 views)
2018-04-24 18:15:36
A NON-ideal modular configuration for Eclipse with JavaFX
by philfrei
2019-12-19 19:35:12

Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!