Our current method of deploying the game involves packaging the jar into an executable. Normally, this is done using `launch4j`, but that requires distributing a copy of the Java Virtual Machine along with the new executable. This requires us to put everything in zip file, which isn't as intuitive as it could be for a typical user. To solve this, we will use a tool that comes included with java versions 14 and higher, called `jpackage`. This will not only package the program into an executable, but it will be in the form of an installer.
To start, you will want to export the FreshmanRPG client to a Jar file.
### If using IntelliJ...
1. Open the FreshmanRPG project in IntelliJ.
2. On the rightmost panel, click Gradle.
3. Under GameClient-desktop, click shadowJar, under shadow.
### If creating the Jar manually...
1. Navigate into `FreshmanRPG/GameClient-desktop`
2. Open a command prompt or terminal in that directory.
3. Run this command: `..\gradlew shadowJar`
<br>
# Finding the Jar file
Once created, the jar file will be in the following path:
Create a folder that you will dedicate to `jpackage`. **Don't create it inside of the repository.**
Next, go into your new folder, and create a folder, called `inputDir`, inside of it. Place your Jar file inside of that folder. The directory structure should look like this:
-`jpackage/inputDir/GameClient-linux.jar`
Next, find a file called `rpg_icon.ico`. It should exist in the FreshmanRPG Google Drive. Place that in the inputDir folder:
-`jpackage/inputDir/rpg_icon.ico`
> **It is very important that you DO NOT place these files directly in your jpackage folder. Move them into the inputDir folder. If you ignore this step, there's a bug in jpackage that will create a large folder that will take up space and be very difficult to delete.**
Now that you have those files, go into the jpackage directory, outside of inputDir, and create a new batch script:
- You can now run the new batch script by double-clicking it. It will create an installer in the jpackage folder you created.
<br>
# What the Command Does
-`--input:` specifies the folder where the Jar file and icon are stored. **Do not make this your current directory, i.e. do not specify "." as the input directory, due to the bug mentioned above.**
-`--name:` the name of the executable that will be installed
-`--main-class:` Java main class
-`--win-shortcut:` creates a desktop shortcut when the installer is run
-`--icon:` adds the icon to the executable that will be installed