Class declaration bug (NoClassDefFoundError caused by ClassNotFoundException)
- by aladine
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.