How do I fix the no lwjgl in java.library.path?

If you have reached this page is probably because you have seen an error message something like this :-

Native library not set - go to http://www.jmonkeyengine.com/wiki/doku.php?id=no_lwjgl_in_java.library.path for details.
java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path
   at java.lang.ClassLoader.loadLibrary(Unknown Source)
   at java.lang.Runtime.loadLibrary0(Unknown Source)
   at java.lang.System.loadLibrary(Unknown Source)
...

This is one of the most commonly asked questions about JME, and this Runtime error is usually a result of not following the setup instructions closely enough, or making a mistake doing so.

The root cause is that the jogl (Java OpenGL) and lwjgl libraries (Light-weight Java Graphics Library) come in two parts:

  • One part is standard Java JAR files that go on the class path.
  • The other part is "native" components that go on the java library path.

You recognize native dynamic libraries by suffixes such as .dll, .so, .dylib, .jnilib. Natives enable the Java framework to access the operating system's OpenGL drivers, and you cannot go without them when developing a platform-independent JME app. JME includes all necessary natives for the major operating systems (Windows (32/64 bit), Linux (32/64 bit), Mac OS X, Solaris) – but you need to link them correctly.

There are a number of different ways of correctly specifying the location of the native libraries:

For Eclipse users.

The preferred way is to set it on the lwjgl.jar library as described below and in the Eclipse Guide for jME - step 10.

Assuming you have already added the lwjgl.jar to your project - locate it in the libraries (project properties → java build path → libraries tab. Now expand the branch, and you should see “Native library location”. Select this, then click edit. Now click workspace, and browse to you JME project → lib → lwjgl → native → <whatever OS you are using> either linux, macosx, solaris or windows.

For Netbeans users

Open the Project Properties, go to the Run section, and add your -Djava.library.path=”…” to the VM options. The path should point to the directories that contain the natives.

See the guide for setting up netbeans 6.7 for jme 2.0 or setting up netbeans 6.7 for jme 2.0.1 (all netbeans tutorials)

For anything

Another way of linking to native dynamic libraries is to add the path to the java command line arguments.

java -jar MyGame.jar -Djava.library.path=${JME-dir}/lib/lwjgl/native/${operating-system}/

Note: For JME 2.0.1, the native libraries are spread over several directories. So the Java library path must contain a list of all these directories. Use a colon for concatenation. If you link all natives, it may look like this:

-Djava.library.path="../jME2_0_1-Stable/lib/lib/lwjgl/native/macosx/:../jME2_0_1-Stable/lib/lib/jogl/native/macosx/:../jME2_0_1-Stable/lib/lib/lwjgl/native/linux_amd64/:../jME2_0_1-Stable/lib/lib/jogl/native/linux_amd64/:../jME2_0_1-Stable/lib/lib/lwjgl/native/linux_i586/:../jME2_0_1-Stable/lib/lib/jogl/native/linux_i586/:../jME2_0_1-Stable/lib/lib/lwjgl/native/solaris_i586/:../jME2_0_1-Stable/lib/lib/jogl/native/solaris_i586/:../jME2_0_1-Stable/lib/lib/lwjgl/native/windows_amd64/:../jME2_0_1-Stable/lib/lib/jogl/native/windows_amd64/:../jME2_0_1-Stable/lib/lib/lwjgl/native/windows_i586/:../jME2_0_1-Stable/lib/lib/jogl/native/windows_i586/"

If you still cannot get it working - please search the forum and the wiki before asking this question again. There are at least a dozen separate threads detailing every possible variation of this issue. Thank you.


/var/www/wiki/data/pages/no_lwjgl_in_java.library.path.txt · Last modified: 2009/10/26 11:29 by zathras  
Recent changes · Show pagesource · Login

Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki

subscribe to jME latest jme headlines


site design by bleedcrimson designs © 2008