Distributing Your LWJGL Application
Distributing your LWJGL Application
There are 2 ways to distribute your application, either as a desktop (standalone) window or as an applet in a browser.
For instructions on how to deploy it as an applet, visit this wiki.
There are many ways to deploy to the desktop:
- If you want to launch it by double clicking your application's JAR file, you will have to leave the natives in the same folder and modify the JAR's manifest to include all dependent JAR files in the classpath like so:
Manifest-Version: 1.0 Main-Class: full.name.of.MainClass Class-Path: lwjgl.jar libs/AnotherJarFile.jar
Class-Path is a space separated list of JAR files. Don't forget to leave an empty line at the end.
- If you want to put the natives in a subfolder, you could either create a batch file or use LWJGL's hidden "librarypath" switch.
To create a batch file for Windows or a shell script for Unix, it should look like so:
java -Djava.library.path="natives/" -jar MyJar.jar
To use the hidden switch, this should be the first call in your main method:
System.setProperty("org.lwjgl.librarypath", new File("natives").getAbsolutePath());
You will still have to setup the classpath like in previous option for both ways.
- If you want everything in 1 JAR file, the JarSplice tool will create a single executable jar from all your jars and at the same time include the native files inside.
- Java Web Start is deployment technology created originally by Sun and is shipped and installed with all Oracle Java run times. It allows java to run a jnlp (xml) file and start your application. Where its setup correctly it can allow launching an external java application directly from a web browser.
- Getdown is an alternative to Java Web Start and considered by many to be superior. GetDown is a deployment system which aims to provide a system for downloading and installing a collection of files on a user's machine and upgrading those files as needed. Though just any collection of files would do, Getdown is mainly intended for the distribution and maintenance of the collection of files that make up an application. It is used by some of the high profile LWJGL game companies like ThreeRings and OddLabs to distribute their games.
- There are a number of tools available to automatically create platform specific executable files for you such as Launch4J, JSmooth or Exe4J to create .EXE files for windows or JarSplice to create Windows EXE files, OS X APP Bundles or Linux ShellScripts.
- Installer Software - These are Installer/Setup programs that are executables themselves and will install applications on the system they are run on, some are cross-platform while others are designed for a specific platform. They usually guide users through the installation procedure with a set of dialogs and instruction screens. You can use these to create installers for LWJGL applications and if required also embedded the JRE with them. Some examples include NSIS, lzPack, InstallBuilder, etc. A full list of Installers can be found here.
- Compiling LWJGL Application to native code. This method will compile your java code to native code and provide you a proper native executable binary (unlike the above tools which just wrap executables that work like a batch script and still use java). However there are many advantages and disadvantages to compiling java to native code. The two common tools to achieving this are the free GCJ compiler or the commercial Excelsior Jet (free for for non-commercial or reduced price for smaller companies) application. Both can be made to work with LWJGL.