Running Demos in Linux from the command line - NoClassDefFoundError

I’ve been messing around for a while now trying to figure out how to get the demos to run under linux.  I’ve probably done something very simple wrong, but can’t seem to get them going.

Through the myriad of searches and digging I found this link:

This leaves me with /install and /jme directories.  Going into the /jme directory I run ant dist-all which compiles with a fair number of warnings, but no errors.  run ant dist-test, same as before.  So now I try to run the demos… I have yet to find a command run from either /install or /jme that effectively runs any of the demos.  :expressionless:

I can’t remember where I found the demo commands - especially the page that mentioned using the * shortcut if you are using Java 6+.  Since I am using Java 6, I used the following command from within the /jme directory.  Note: I have replaced the ; with : since I am running Linux.

java -Djava.library.path=./lib -cp ./lib/*:./target/* jmetest.renderer.TestCylinder

Terminal Output:

Nov 9, 2008 2:00:13 AM start
INFO: Application started.
Nov 9, 2008 2:00:13 AM com.jme.system.PropertiesGameSettings <init>
INFO: PropertiesGameSettings created
Nov 9, 2008 2:00:13 AM com.jme.system.PropertiesGameSettings load
WARNING: Could not load properties. Creating a new one.
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: [Lorg/lwjgl/opengl/DisplayMode;
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(
        at java.lang.Class.getDeclaredMethod(
        at java.awt.Component.isCoalesceEventsOverriden(
        at java.awt.Component.access$100(
        at java.awt.Component$
        at java.awt.Component$
        at Method)
        at java.awt.Component.checkCoalescing(
        at java.awt.Component.<init>(
        at java.awt.Container.<init>(
        at java.awt.Window.<init>(
        at java.awt.Window.<init>(
        at java.awt.Dialog.<init>(
   at java.awt.Dialog.<init>(
   at javax.swing.JDialog.<init>(
   at javax.swing.JDialog.<init>(
   at javax.swing.JDialog.<init>(
   at com.jme.system.lwjgl.LWJGLPropertiesDialog.<init>(
   at java.awt.event.InvocationEvent.dispatch(
   at java.awt.EventQueue.dispatchEvent(
   at java.awt.EventDispatchThread.pumpOneEventForFilters(
   at java.awt.EventDispatchThread.pumpEventsForFilter(
   at java.awt.EventDispatchThread.pumpEventsForHierarchy(
   at java.awt.EventDispatchThread.pumpEvents(
   at java.awt.EventDispatchThread.pumpEvents(
Caused by: java.lang.ClassNotFoundException: org.lwjgl.opengl.DisplayMode
   at Method)
   at java.lang.ClassLoader.loadClass(
   at sun.misc.Launcher$AppClassLoader.loadClass(
   at java.lang.ClassLoader.loadClass(
   at java.lang.ClassLoader.loadClassInternal(
   ... 28 more

I have tried the longer commands as well, also resulting in a lot of errors.  Not really sure what I am doing wrong here.  My assumption is that the classpath or library paths are wrong, but at this point I have no clue what else to try.  I figured I would get it working in the command line before trying to mess with Geany, Eclipse, or NetBeans.

In case it helps:
OS: Ubuntu 8.04
Java:  1.6.0_07 (Sun Java JDK/JRE, not gjc)
Ant: 1.7.0

Are you using jme2 ? i assume yes.

The class which is not being found org/lwjgl/opengl/DisplayMode is in lwjgl.jar.

Which is in the folder: lib/lwjgl/  (in jme1 it was in lib/).

I think * only works for all jars in the specified directory, not recursively.

also your java.library.path should point to liblwjglnativelinux

Yes, I am using jme2.  Forgot to mention I did ant jMe_v2 when I used the antbuildscript.  Also correct on the , modifying the classpath to have each directory for the libs works.  Thanks for the help, it is much appreciated.

Working command:

java -Djava.library.path=./lib/lwjgl/native/linux -cp ./lib/jogl/
:./lib/jorbis/:./lib/junit/:./lib/lwjgl/:./lib/swt/:./target/* jmetest.renderer.TestCylinder

So, for a guide for linux (at least ubuntu in particular users):

  • Open Your favorite terminal.

  • Install required applications *
      [li] sudo aptitude install ant ant-optional ant-doc subversion 
  • Create a directory (the example command below makes /home/<user name>/projects/jme2 )
      [li] mkdir ~/projects/jme2
  • Create a blank build.xml file in~/projects/jme2 **
      [li] gedit ~/projects/jme2/build.xml
  • Copy the script from
    and paste it into the build.xml file.  Save and exit the program.

  • Run the following terminal commands:
      [li]cd ~/projects/jme2

    • ant jMe_v2
  • Run Demos and see if it all worked
      [li]cd ~/projects/jme2/jme
    • java -Djava.library.path=./lib/lwjgl/native/linux -cp ./lib/jogl/*:./lib/jorbis/*:./lib/junit/*:./lib/lwjgl/*:./lib/swt/*:./target/* jmetest.renderer.TestCylinder
  • Run all the other demos you  want.

* These are only for jMe_v2!  Add "cvs" and "tkcvs" (without quotes) to the list for jMe_v1.
   Note: you can also use apt-get install if you like.
** gedit or nano, vim, leafpad, <insert favorite text editor here>.

There are some other things for jMe_v1 as noted on the page with the script.  Notably, the username and password used for CVS.

Anyways, hope this helps other people like me that got confused.

If you checked out jme2 from svn you should also be able to run the ant target "run_testchooser" to get a selection list of all test classes to choose from!

Interesting tidbit there.  I had haphazardly noticed the run-testchooser target when I was messing with the build.xml, using it as a reference to learn how to make a build.xml forr one of my own little side projects.  :D  Figured I'd do something productive while taking a break from trying to get the demo's working.

Anyways, when I try to use run-testchooser the actual chooser runs perfectly, but for some reason the demo's mostly do not.  Looking at the error messages, it seems to be a similar culprit.  The java.library.path doesn't have LWJGL.

[java] Nov 9, 2008 3:45:13 PM class jmetest.effects.TestDynamicSmoker start()
     [java] SEVERE: Exception in game loop
     [java] java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path
     [java]    at java.lang.ClassLoader.loadLibrary(
     [java]    at java.lang.Runtime.loadLibrary0(
     [java]    at java.lang.System.loadLibrary(
     [java]    at org.lwjgl.Sys$
     [java]    at Method)
     [java]    at org.lwjgl.Sys.doLoadLibrary(
     [java]    at org.lwjgl.Sys.loadLibrary(
     [java]    at org.lwjgl.Sys.<clinit>(
     [java]    at org.lwjgl.opengl.Display.<clinit>(
     [java]    at com.jme.system.lwjgl.LWJGLPropertiesDialog$
     [java]    at
     [java]    at
     [java]    at jmetest.effects.TestDynamicSmoker.main(
     [java]    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     [java]    at sun.reflect.NativeMethodAccessorImpl.invoke(
     [java]    at sun.reflect.DelegatingMethodAccessorImpl.invoke(
     [java]    at java.lang.reflect.Method.invoke(
     [java]    at jmetest.TestChooser.start(
     [java]    at jmetest.TestChooser.main(
     [java] Nov 9, 2008 3:45:13 PM cleanup
     [java] INFO: Cleaning up resources.
     [java] Nov 9, 2008 3:45:13 PM com.jme.system.lwjgl.LWJGLDisplaySystem <init>
     [java] INFO: LWJGL Display System created.
     [java] Nov 9, 2008 3:45:13 PM start
     [java] INFO: Application ending.

/facepalm  I figured it out!

   <target name="run-testchooser" depends="compile-test" description="Runs the TestChooser">
      <java classname="jmetest.TestChooser" fork="true" classpathref="classpath">
         <jvmarg value=  "-Djava.library.path=${libs}/jogl/native/windows_i586:${libs}/lwjgl/native/linux:${libs}/lwjgl/native/macosx:${libs}/lwjgl/native/win32:${libs}/swt/linux:${libs}/swt/macosx-carbon:${libs}/swt/macosx-cocoa:${libs}/swt/windows"/>

All I had to do was change the ; to :  -  but build.xml should probably be modified to use a property that has its value set base on the OS.  So it will auto switch from inserting ; to : based on Win/Mac/*nix.  I'm not really certain how to do that at this time, as my experience with ant is literally 1 night of tinkering.

Ow my bad! I can't believe I overlooked that when "fixing" the build.xml.

I'm not so sure what to do about it either, I am an ant novice myself and don't know out of my head how to determine the operating system used in an ant target. Maybe somebody else can help here?

I've been doing some digging and found that when you do a typical pathref like is done for classpath, it automatically converts ; to : appropriately, however in this case it's a string passed as an arg and doesn't.  I tried a bunch of ways to get a path to work, but I guess you can't set the environment variable for java.library.path using ant.  Only through the arg with a string.  Which leaves a convoluted if/then/else wanna be structure as the answer.  So this seems to work on Linux - I don't have windows on my box to test it under win/mac/etc.

   <target name="get-os">
         <condition property="os.islinux">
                   <equals arg1="${}" arg2="Linux"/>
   <target name="set-sep" depends="get-os" if="os.islinux">
      <property name="sep" value=":" />
   <target name="set-sep2" depends="set-sep" unless="os.islinux">
      <property name="sep" value=";" />

   <target name="run-testchooser" depends="compile-test, set-sep2" description="Runs the TestChooser">
      <property name="lib.path.arg" value="-Djava.library.path=${libs}/jogl/native/windows_i586${sep}${libs}/lwjgl/native/linux${sep}${libs}/lwjgl/native/macosx${sep}${libs}/lwjgl/native/win32${sep}${libs}/swt/linux${sep}${libs}/swt/macosx-carbon${sep}${libs}/swt/macosx-cocoa${sep}${libs}/swt/windows" />
      <echo> $${lib.path.arg}=${lib.path.arg} </echo>
      <java classname="jmetest.TestChooser" fork="true" classpathref="classpath">
         <jvmarg value="${lib.path.arg}"  />

The echo is in there for testing purposes and can be removed later.  It works for me so far though.

Thanks! I had the same issue, your fix worked for me. Can someone try it on the other OS so it could be committed to the repo?