Package com.jme.app does not exist

I just installed jME on Arch Linux, from the AUR.  When I try compiling the hello world program though it can't find any of the include packages.  I'm just trying to compile it with a 'javac helloworld.java', should I be doing something else, or is that right and I just didn't install it correctly?



Thanks!

You will have to specify a classpath for the jar files of jme as well so the compiler can find the jme classes. You will also have to specify this when you want to start the application.



Hope this helps,

Normen



Edit: and wait, there is really a package for archlinux? what version of jme is it?

Thank you, I got past that first error with 'javac -cp /usr/share/java/jme/jme.jar helloworld.java', but now it can't find the variable 'SimpleGame.ALWAYS_SHOW_PROPS_DIALOG', is there another file I need to put in the classpath?



And ya there is a file in the Arch Users Repo, it's jme-svn, version 5165-1?



e:  I guess I should post my code, so people don't have to go look it up…


import com.jme.app.SimpleGame;
import com.jme.scene.shape.Box;
import com.jme.math.Vector3f;

/**
 * Started Date: Jul 20, 2004<br><br>
 * Simple HelloWorld program for jME
 *
 * @author Jack Lindamood
 */

public class Ball extends SimpleGame{
   
 public static void main(String[] args) {
   
  Ball app = new Ball(); // Create Object
  // Signal to show properties dialog
  app.setDialogBehaviour(SimpleGame.ALWAYS_SHOW_PROPS_DIALOG);
  app.start(); // Start the program
 
 }
 
 protected void simpleInitGame() {
   
  // Make a box
  Box b = new Box("Mybox", new Vector3f(0,0,0), new Vector3f(1,1,1));
  rootNode.attachChild(b); // Put it in the scene graph
 
 }
}

Lunnies said:

Thank you, I got past that first error with 'javac -cp /usr/share/java/jme/jme.jar helloworld.java', but now it can't find the variable 'SimpleGame.ALWAYS_SHOW_PROPS_DIALOG', is there another file I need to put in the classpath?

And ya there is a file in the Arch Users Repo, it's jme-svn, version 5165-1?

Wow, thats a very recent version, seems that the archlinux package updates from svn automatically, cool :D

Your classpath is not complete yet, there should be more in it including the jar files of lwjgl or jogl (whichever you want to use) and the native libraries for your platform.
Normally jme2 is split into multiple jar files, named jme-audio.jar, jme-effects.jar etc. so I dont know if that is so in the distribution you downloaded. Of course you only need to import those parts you want to use. Also, I dont know where this helloworld.java is from and if it does things right, maybe you should check out our wiki for some tutorials.

Edit: the ALWAYS_SHOW_PROPS_DIALOG variable is apparently not in jme2, that helloworld file is definitely outdated.

Thanks, I was using an old Wiki article here but found the updated ones.



I get the error


Exception in thread "main" java.lang.NoClassDefFoundError: Ball
Caused by: java.lang.ClassNotFoundException: Ball
        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: Ball.  Program will exit.



Now, compiling with 'javac -cp /usr/share/java/jme/*:/usr/share/java/jme/lib/* Ball.java' and running with 'java -Djava.library.path=/usr/share/java/jme/lib -cp /usr/share/java/jme/*:/usr/share/java/jme/lib/* Ball'.

My code is now

import com.jme.app.SimpleGame;
import com.jme.scene.shape.Box;
import com.jme.math.Vector3f;
 
/**
 * Started Date: Jul 20, 2004<br>
 * <br>
 * Simple HelloWorld program for jME
 *
 * @author Jack Lindamood
 */
public class Ball extends SimpleGame {
   public static void main(String[] args) {
      Ball app = new Ball(); // Create Object
      // Signal to show properties dialog
      app.setConfigShowMode(ConfigShowMode.AlwaysShow);
      app.start(); // Start the program
   }
 
   protected void simpleInitGame() {
      // Make a box
      Box b = new Box("Mybox", new Vector3f(0, 0, 0), new Vector3f(1, 1, 1));
      rootNode.attachChild(b); // Put it in the scene graph
   }
}



Thank you very much for the help!

You cannot set a classpath to all jars with "*" you will have to import all jars and the correct natives folder.

Coding java from the command line can be quite… inconvenient, I suggest you look into using an IDE like NetBeans or Eclipse, there is instructions on how to set up jme for both in the wiki.

Are you sure?  The Wiki says that Java newer than 6 can use the wildcards in the classpath.



I'm using Geany, so I'm not exactly using the command line - it's just not a full fledged IDE.  I'm going through the Java3D included in Java, but I'll come back to jME eventually and if I can't get it working still I'll use Eclipse.



Thank you, you've been very helpful :slight_smile:

if you need up-to-date examples, make sure to use the code directly from the svn, not from the wiki

http://code.google.com/p/jmonkeyengine/source/browse/#svn/trunk/src/jmetest/TutorialGuide