Class declaration bug
        Posted  
        
            by aladine
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by aladine
        
        
        
        Published on 2010-06-07T04:15:19Z
        Indexed on 
            2010/06/07
            4:22 UTC
        
        
        Read the original article
        Hit count: 373
        
java
Please advise me what's wrong with this class declaration:
ExchEngine.java
package engine;
public class ExchEngine {
    public ExchEngine() {
    }
    public static void main(String[] args) {    
        ExchEngine engine=new ExchEngine() ; 
    }
}
When I compile this file, I always get exception:
java.lang.NoClassDefFoundError: test_engine/ExchEngine
Caused by: java.lang.ClassNotFoundException: test_engine.ExchEngine
    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)
Exception in thread "main"
This seems very weird that ExchEngine.java is inside a package and it cannot run itself. Thanks for any help.
© Stack Overflow or respective owner