-
-
Notifications
You must be signed in to change notification settings - Fork 436
Configuring Self Update
The bootstrap program:
- Downloads the launcher from your website.
- Chooses a standard folder to store the launcher's files (in My Documents or the home folder).
- Updates the launcher automatically.
One of the sample files is latest.json. In it, it contains a link to a pack-compressed version of the launcher for download, as well as the latest launcher version.
The file looks like:
{
"version": "4.0.1",
"url": "http://example.com/versions/4.0.1.jar.pack"
}The version should correspond to the version in build.gradle (in the source code). Change "4.0.1" to whatever version is in build.gradle at the moment.
You can also change the version to build.gradle to whatever you want. Unlike the package/modpack version, this version must be a proper version string (X.Y.Z), and you should always increase it. Note that 1.1.10 is greater than 1.1.9, and 1.2.0 is greater than both 1.1.9 and 1.1.10.
Take the launcher file and run it through the pack200 tool that comes with the JDK. Upload this to the website and also change the URL in latest.json (also on your site).
pack200 --no-gzip launcher.jar.pack launcher-X.Y.Z-all.jar
(That command makes launcher.jar.pack from launcher-X.Y.Z-all.jar in the same folder.)
Inside the folder launcher-bootstrap/src/main/resources/com/skcraft/launcher/ will be:
-
lang/, which contains language files you should change -
bootstrap.properties, which contain important settings you must change -
bootstrapper_icon.png, which is the bootstrapper icon
The properties file is one of the most important. It looks like:
homeFolderWindows=Example Launcher
homeFolder=.examplelauncher
launcherClass=com.skcraft.launcher.Launcher
latestUrl=http://example.com/latest.json- "homeFolderWindows" is the folder in "My Documents" (i.e.
C:\Users\Name\Documents\Example Launcher) - "homeFolder" is the folder in the user's home folder (i.e.
/home/.examplelauncher) - "launcherClass" does not need to be changed unless you are using the Fancy Launcher
- "latestUrl" should point to
latest.jsonon your website
- Recompile the entire launcher again (using
gradlew clean build). - Double click the
-all.jarfile inlauncher-bootstrap/build/libsto make sure it works. - Check your home folder (BSD/Linux/Mac OS X users) or
My Documents(Windows users) to see the folder name that you used.
If everything works, you are done! Give players a copy of the bootstrapper -all.jar file.
While you can provide the .jar for download, it comes with two downfalls: (1) the file will be useless if Java is not already installed; and (2) your launcher will have no program icon.
There are two ways to solve the problem:
- Create .exe and .app wrappers for Windows and Mac OS X.
- Create an installer that automatically installs Java and sets up shortcuts.
There are several tools that create an .exe from a .jar:
The author has personal experience with launch4j and can recommend it, but the other options may work even better.
Warning: Later versions of Internet Explorer and Google Chrome will mark executables as untrustworthy by default unless they have been downloaded thousands of times, the executable is downloaded from a trusted website, or the executable has been been digitally signed (which involves the cost of a "code signing certificate"). To run an untrusted executable, the user has to find a hidden "ignore this warning" button.
Signing the executable is the easiest solution to this problem, but it does come with monetary costs. If you want to instead rely on your executable accruing many downloads, make sure to use the bootstrapper (and not the launcher) for your executable. Why? Every time you release a new .exe, you start over with a new download count. You never need to update the bootstrapper.
With the bootstrapper, you can still release as many launcher updates as you want.
Apple provides tools to create .app bundles of .jar files.
Windows users without access to Mac OS X can create .zip.app bundles using Maven, Ant and Gradle, but this is outside the scope of the article. Since the launcher is already built using Gradle, modifying the build files to also produce .zip.apps is perhaps the easiest approach. Be aware, however, that the Gradle plugin for building these Mac OS X applications is pretty limited compared to its Maven plugin counterpart, and did not even work for the author.
It is possible to build a Linux package for every Linux distribution that you are interested in, but this is outside the scope of the article. It is easiest to just provide the .jar for Linux users.
Here's an example of a SKCraft Launcher package for Arch Linux. It is specifically for sk89q's server.
It's also possible to provide an .sh file that the user can run.
If you prefer creating an installer, there are many options available to you. The author has no experience with creating an installer for Java applications, and so the following is only general advice.
Some tools can target Windows, Mac OS X, and Linux all in one go. Other tools can only create an installer for one platform. When looking for an installer, look out for its support of Java applications. For example, support for running .jar files is important, as well as the ability to automatically download and install the JRE.
Windows has a built-in installer framework called Windows Installer, whose files are often identified with an .msi extension. Some Windows-targeted installer builders use this framework, while others don't.
- Windows target:
- Multi-platform target:
- IzPack is an open source installer builder that is built on Java.
- install4j is a commercial installer builder specifically for Java applications.
- InstallBuilder is a commercial installer builder.
- Advanced Installer is a popular commercial installer builder.
- InstallShield is a popular commercial installer builder.
By no means is this an exhaustive list.
Whenever you want to push an update:
- Update the version in
build.gradle(NOTE: Unlike the versions for modpacks, this version should actually be a proper version like #.#.# or #.#, or #). - Recompile the launcher.
- Upload the pack-compressed version of your .jar.
- Update the version number and URL in
latest.json.
You never should need to update the bootstrapper.
Need help? See Getting Help.
Tutorial
Launcher Features:
- Fancy Launcher
- Portable Mode
- Hidden Modpacks
- Deploying Server Modpacks
- Launcher Arguments
- Custom JAR (.jar mods)
- Custom Version Manifest
Customization:
- Localization
- News Page Guide
- Custom Microsoft OAuth application
- Using an IDE (Eclipse, IntelliJ)
Additional Reading:
Find the launcher useful?
Donate to obw, the current maintainer:
Donate to sk89q, the original maintainer:


