Downloading and Setting Up LWJGL
From LWJGL
What you need
You'll need to first get the lwjgl package from the lwjgl download page. Its recommended you use a stable release as the nightly build may contain issues and be unstable. There are 4 packages you can choose to download but lwjgl-[version].zip is all you should need to get going. lwjgl-source-[version].zip, lwjgl-docs-[version].zip and lwjgl_applet-[version] are all optional packages and should be self explanatory as to what they are.
How to install LWJGL?
This is a question may people ask, the answer to which is that you do not install lwjgl. It should not be put in any system/jre folder nor is there any method to install it on the system. LWJGL is a library and intended to be used as such, you must include it with your java application and simply point to it when the jvm is launched.
Setting up LWJGL
LWJGL consists of two parts, a java part and a native code part. You must setup both of these parts properly in order for lwjgl to work. In order to setup the java part you must add lwjgl.jar to the classpath (as an external library jar). As for the native part (*.dll files on windows, *.so on linux, *.jnilib on mac, etc) you must tell java which folder the natives are located in for LWJGL to be able to find them (use the -Djava.library.path=path/to/dir vm parameter to do this).
I keep getting an java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path
This is because the native part is not setup correctly. Add a -Djava.library.path=path/to/dir to the commandline or as an VM option in your IDE so that lwjgl is able to find the folder containing the native files.
Testing LWJGL
Go to where you extracted lwjgl-[version].zip. The information provided below was taken from doc/README:
- Windows
- Open a command prompt and navigate to the folder where the archive was extracted (i.e., by using the cd command). Then issue the following command (all in one line):
- java -cp .;res;jar\lwjgl.jar;jar\lwjgl_test.jar;jar\lwjgl_util.jar;jar\jinput.jar; -Djava.library.path=native\windows org.lwjgl.test.WindowCreationTest
- Open a command prompt and navigate to the folder where the archive was extracted (i.e., by using the cd command). Then issue the following command (all in one line):
- Mac OS X
- Open a terminal and navigate to the folder where the archive was extracted (i.e., by using the cd command). Then issue the following command (all in one line):
- java -cp .:res:jar/lwjgl.jar:jar/lwjgl_test.jar:jar/lwjgl_util.jar:jar/jinput.jar: -Djava.library.path=native/macosx org.lwjgl.test.WindowCreationTest
- Open a terminal and navigate to the folder where the archive was extracted (i.e., by using the cd command). Then issue the following command (all in one line):
- Linux/BSD
- Open a terminal and navigate to the folder where the archive was extracted (i.e., by using the cd command). Then issue the following command (all in one line):
- java -cp .:res:jar/lwjgl.jar:jar/lwjgl_test.jar:jar/lwjgl_util.jar:jar/jinput.jar: -Djava.library.path=native/linux org.lwjgl.test.WindowCreationTest
- Open a terminal and navigate to the folder where the archive was extracted (i.e., by using the cd command). Then issue the following command (all in one line):
- Solaris
- Open a terminal and navigate to the folder where the archive was extracted (i.e., by using the cd command). Then issue the following command (all in one line):
- java -cp .:res:jar/lwjgl.jar:jar/lwjgl_test.jar:jar/lwjgl_util.jar:jar/jinput.jar: -Djava.library.path=native/solaris org.lwjgl.test.WindowCreationTest
- Open a terminal and navigate to the folder where the archive was extracted (i.e., by using the cd command). Then issue the following command (all in one line):
A window should appear, and you should see the following output:
Found <number> display modes 240, 320, WindowCreationTest Display created Moving to 100, 100 Window created 600, 800, Game
You can replace org.lwjgl.test.WindowCreationTest with one of the following:
org.lwjgl.test.SysTest org.lwjgl.test.DisplayTest org.lwjgl.test.input.MouseCreationTest org.lwjgl.test.input.MouseTest org.lwjgl.test.input.HWCursorTest org.lwjgl.test.input.KeyboardTest org.lwjgl.test.input.TestControllers org.lwjgl.test.openal.ALCTest org.lwjgl.test.openal.OpenALCreationTest org.lwjgl.test.openal.MovingSoundTest org.lwjgl.test.openal.PlayTest org.lwjgl.test.openal.PlayTestMemory org.lwjgl.test.openal.SourceLimitTest org.lwjgl.test.openal.PositionTest org.lwjgl.test.openal.StressTest org.lwjgl.test.openal.SourceLimitTest org.lwjgl.test.opengl.FullScreenWindowedTest org.lwjgl.test.opengl.PbufferTest org.lwjgl.test.opengl.VBOIndexTest org.lwjgl.test.opengl.VBOTest org.lwjgl.test.opengl.pbuffers.PbufferTest org.lwjgl.test.opengl.shaders.ShadersTest org.lwjgl.examples.spaceinvaders.Game