Tackling the Dragon – Converting a Java Based Game to Universal Windows Platform

Ragnarök is Nigh.

Hamilton Ontario based Thrive games have been working on their lead game, Dragon of Legends for sometime with aspirations of delivering their game to the Steam platform.  The game uncovers countless mysteries of the past as players battle across platforms in a vibrant 2D world inspired by Celtic and Norse mythology. Our team recently met with the team at Thrive games as they also had expressed interest in having their proprietary game engine utilized on multiple platforms (PC, OSX, Linux, iOS and Android) in order to stay committed to making our game accessible to everyone.

The Java app platform has been the platform of choice for the team at Thrive Games to architect their Norse tale to share with the world.  While Java games could easily be deployed on Steam, the team was looking for a way to offer Dragon of Legends on other platforms without incurring long development cycles.  Being a Kickstarter funded start-up, Thrive Games needed a cost-effective way to reach gamers on other platforms like Windows.

In a collaborative effort, our teams came together to futher the time Thrive games had invested building the proprietary game engine and graphics on Java to be enjoyed on the Universal Windows Platform via a multitude of Windows based devices.

The following was required to be completed to accomplish this:

  1. Convert the JAR file to a non-dependant package file to be converted
  2. Convert the created Win32 application to a UWP app
  3. Submit the completed UWP game to the Windows Marketplace

In addition to the above core goals, the team's stretch goal was to complete the conversation of the Dragon of Legends UWP game in a span of 1 day.

Led by Technical Evangelist Mickey MacDonald, the team's 1st task was to build the JAR package file from the libGDX game engine's output using Gradle. To do this the team ran Gradle from the command line with the command: gradlew desktop:dist

Next the team preformed a few steps to obfuscate the project to help protect the game assets and code from being extracted from the final release. This was accomplished by using ProGuard, and performing the following steps:

  1. Construct a config file (config.pro) file. This file lists all the classes, fields, and methods, that need to be kept and/or that their names need to be keptNOTE: Refer to https://www.guardsquare.com/en/proguard/manual/ for more details on how this is accomplished
  2. Once the config file is created, the team ran ProGuard from the command line, using the command: java -jar proguard.jar @config.pro

Once the obfuscating process had completed we then had a JAR package that could be used for release. The next step was to the create a Win32 executable application. This was completed by using cross-platform Java executable wrapper Launch4j. This wrapper allows a packaged Java application to be run just like a native Win32 application, packaging all dependencies with it, including the JRE (Java Runtime Environment) needed.


Image source: https://launch4j.sourceforge.net

The steps taken to create the executable in Launch4j are as follows:

  1. Launch Launch4J and make sure you are on the Basic tab
  2. On the Output File* input: Browse for the destination where you want your EXE file to be name via this "desktop/...../ProjectName.exe"
  3. On the Jar* input: Browse and locate the jar file you want to convert in your PC
  4. On the Icon input: Locate your ico file for the icon
  5. Go to the JRE tab
  6. On the Min JRE version input: type in: 1.4.0
  7. Click on the gear icon on the top and press save (destination preferably in output file destination, name - "ProjectName")
  8. Press the Play button next to and the Jar file should be converted to EXE

Once completed, the newly created Win32 executable could now be converted to a UWP application using the Desktop Bridge kit. The conversion process itself was done manually due to the game's lack of installer and the developer’s knowledge of the files needed to operate the game. The following steps were completed to convert the Win32 app to a UWP app manually:

  1. Download and installed the Window 10 Software Development Kit
  2. Create the appxmanifest.xml manually
    NOTE: detailed steps found here: /en-us/windows/uwp/porting/desktop-to-uwp-manual-conversion
  3. Open the Command Prompt in administrator mode
  4. Navigate to C:\Program Files (x86)\Windows Kits\10\bin\x86
  5. Entered the following command: MakeAppx pack /d "Path to Files" /p "Application Name".appx

Creation of the appx package of the game is now completed. The following steps were then completed to certificate sign and install the application on the local machine for testing.

  1. Opened the Command Prompt in administrator mode
  2. Navigate to C:\Program Files (x86)\Windows Kits\10\bin\x86
  3. Create a certificate to sign the appx
    NOTE: detailed steps found here https://msdn.microsoft.com/en-us/library/windows/desktop/jj835832(v=vs.85).aspx 
  4. Use the SignTool to sign the application with the created certificate
    NOTE: detailed steps found here https://msdn.microsoft.com/en-us/library/windows/desktop/jj835835(v=vs.85).aspx
  5. The certificate is then installed on the testing computer
  6. Double click the appx and install the application

The process of embedding the dependencies, like the JRE in the final build were a challenge. After some careful consideration and research, the team decided on using Launch4j to address this. Launch4j allowed the team to create a lightweight Windows native executable which allowed bundling of the JRE and any other libraries or dependencies without the need to modify any existing code or infrastructure.

The team at Thrive is now working on finalizing the game and adding the much-anticipated multi-player features. The plan is conduct a worldwide launch on all platforms in the next few months allowing Norse gods to battle it out on multiple devices. Checkout the Dragon of Legend demo currently live on the Windows Store here: https://www.microsoft.com/store/apps/9plhr65j1pr9

Comments

  • Anonymous
    August 10, 2017
    Great post, thank you very much! It works for me! At least for Win 10. Hope it will works on XBOX ONE, that would be huge...I used Packr (https://github.com/libgdx/packr) instead of Launch4j, but otherwise i follow your steps without any problems, nice!