Yet another Java classpath problem

Posted by pypmannetjies on Stack Overflow See other posts from Stack Overflow or by pypmannetjies
Published on 2010-04-25T16:28:33Z Indexed on 2010/04/25 16:33 UTC
Read the original article Hit count: 301

Filed under:
|
|

Hi

I've been working on a project in Netbeans. Now I'd like to submit it and allow the markers to compile it with a script. However, I get the NoClassDefFoundError when I try to run via the command line. Even when setting the classpath to the current directory manually.

javac Main.java works fine

then calling java -classpath . Main gives:

java -classpath . Main
Exception in thread "main" java.lang.NoClassDefFoundError: Main (wrong name: pro
ject2/Main)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12
4)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)

© Stack Overflow or respective owner

Related posts about javac

Related posts about java