NoClassDefFoundError when trying to run jmetest

Hi! It took me hours to download, install and compile the whole stuff required for JME.

So after doing all that I tried to run the examples.

I suppose that jmetargetjmetest.jar file is that right one.



So I called "java jmetest" and all I got was:



Exception in thread "main" java.lang.NoClassDefFoundError: G:CoderProjectsJavajmetargetjmetest



I did "cd G:CoderProjectsJavajmetarget" so that Iam in the right directory, I even added this path to the CLASSPATH. I even tried to extract the jar file and tried to start the class file. Also calling it with the package name did not have any effect: "java jmetest.TestChooser".



Am I plain stupid? What did I wrong? How can I call the test samples?

Yup Core-Dump is right, using an IDE will be monumentally easier.



However I believe the command to run from a command line is…

java -jar -classpath <paths/to/jar/files> -Djava.library.path="<paths/to/directories/containing/native/libraries>" <java_package_containing_the_application.jar>



where <...> is a user supplied path.

Be sure to read The turorials

Especially the getting started guide (Step 6).



It sounds like you don’t have much java experience yet, it might be better if you make yourself comfortable with the language and an IDE like Eclipse first, before trying to create 3D games.



edit:

i don’t want it to sounds harsh, what i want to say is, trying to learn java, the jME API and OpenGL at the same time can be frustrating.

Its better to take small steady steps that to run and stumble all the time :slight_smile:

Thank you for the help. Iam definitely not new to programming and 3D programming itself.

But Iam new to java, as my professor is forcing us to do a java project in this year, so I have to find my way through it :slight_smile:



I now tried: java -jar jmetest.jar



And the output was:



07.03.2008 18:48:12 jmetest.TestChooser start

INFO: Composing Test list…

Exception in thread "main" java.lang.NoClassDefFoundError: org/lwjgl/Sys



I suppose I have to also add the lwgl jar files and dlls to the classpath or pass it as argument to the java interpreter, but I hope I will get this running alone.



When deciding which 3D engine to use, I heard that JME would have a great and nice community…and indeed it has!



I will tell you if I got stuck again, but now I have to go, I must try it tomorrow, thank you again!

I had the same problem when I first downloaded the test code.  There seems to be an error somewhere in the manifest.  For my other projects, I have created a simple "app-launcher.jar" file that uses its own URLClassLoader to load jar files to its classpath in a specified directory.  You can place this jar with the other jme jars.  So at the command line you could type:

java -jar "app-launcher.jar" jmetest.TestChooser .


This way you do not have to worry about messy manifests with long "Class-Path" entries.  All you have to do is specify the name of the main class at the command line, and it starts up your app.  Here is a link to that file:
https://webshare.uchicago.edu/users/jmontgomery/Public/app-launcher.jar
It is easier, though, to use an IDE like Eclipse and checkout the latest version from cvs. The link to the Eclipse tutorial is http://www.jmonkeyengine.com/wiki/doku.php?id=setting_up_eclipse_to_build_jme There have been many updates to 1.0 since the original release last October.  Checking out the latest version from HEAD ensures that you get these updates.  The latest cvs version of jme does not have this issue with the test package.

I have included the code for app-launcher.jar below in case anyone is interested:



import java.io.File;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

/**
 * A utility class that adds jars in a specified directory to the classpath of a
 * custom class loader and then invokes the main method of the specified main class
 * using that class loader to resolve the class.
 *
 */
public final class Main
{
   /**
    * Application entry point.
    *
    * @param rawArgs First argument to main is the name of the main class to use.
    *                Second argument to main the name of the directory containing the jar files.
    * @throws Exception
    */
   public static void main(String[] rawArgs) throws Exception
   {
       if(rawArgs.length < 2)
       {
         throw new IllegalArgumentException("USAGE: [Name of the main class] [jar directory]");
       }
       final String mainClass = rawArgs[0];
       final String libDir = rawArgs[1];
        //specify, a directory from which to load the jars
        File rootDir = new File(libDir);
        List<URL> urls = new ArrayList<URL>();
        for(File f : rootDir.listFiles())
        {
          if(f.getName().toLowerCase(Locale.ENGLISH).endsWith(".jar"))
             urls.add(f.toURL());
        }
       
        // add those jars to your custom class loader
        // we can just use the existing URLClassLoader class since it does what
        // we need
        ClassLoader cl = new URLClassLoader(urls.toArray(new URL[urls.size()]));
        // instantiate your "secondary main class" that initializes your app
        String[] args = new String[rawArgs.length-2];
        if(args.length != 0)
           System.arraycopy(rawArgs, 2, args, 0, args.length);
        Class<?> clazz = Class.forName(mainClass,true,cl);
        // if clazz doesn't need the args in its constructor
        // then we could just use clazz.newInstance() to instantiate an instance
        // of that class
        // if we need args, then must use reflection api to instantiate
       Method mainMethod = clazz.getMethod("main",String[].class);
       Object param = args;
      
       mainMethod.invoke(null, param);
   } //end main
}

Nice for those ppl that want to use cmd line Anubis, have you posted this in the user code section?