Reputation: 39437
I downloaded a program implemented in Java (in this case, http://julian.togelius.com/mariocompetition2009/index.php). I first tried opening the Play.class file with Java, but it spit out an error i couldn't see because the console window disappeared so fast. I replicated this on the command line, and got the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: Play/class
Caused by: java.lang.ClassNotFoundException: Play.class
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: Play.class. Program will exit.
What do i have to do to get this to run properly? (If this belongs on Superuser then that's fine.)
Upvotes: 0
Views: 271
Reputation: 199215
You have to invoke the program without the .class
java Play
instead of
java Play.class
EDIT
Further explanation of the problem
( or whatever the full class name is )
For instance if you have a class defined like this:
package a.b.c.d;
public class MyClass {
public void main( String [] args ) {
System.out.println( "Hey there");
}
}
You can compile it like this:
javac -D . MyClass.java
The -D . option is used to tell the compiler where to create the package structure. In this case it is "." ( current directory )
Which will create the following directory structure
a\b\c\d\MyClass.class ( assuming windows )
To run it you use:
java a.b.c.d.MyClass // with the full package name and wihtout the .class
See this.
Upvotes: 8
Reputation: 5798
from the website you linked:
How to participate (it's easy!) If you plan to participate, you should join the Mario Competition Google Group. All technical and organizational questions should be posted to this group, where they will be answered by the organizers and stored in a searchable achive.
But first you will have to develop your controller, using your method of choice and the Java software package. First of all, look at the getting started page; more technical information coming soon.
From the getting started page
java ch.idsia.scenarios.Play
In other words: first start reading on the website then come back here
Upvotes: 3
Reputation: 21838
Looks like a path problem. One easy solution is to copy Play.java to the directory in which the java executable resides. A better solution would be to add the path to your java executables in the default system path and call java from the directory containing Play.java
Upvotes: 0