So...I have just begun to whet my appetite for Java today, and I have already run into a stumbling block. When I put my code in a .java file and compile it (via javac), I receive no errors. However, when I actually run my script, I receive quite the nasty error which I seem to not be able to comprehend. The error is as follows:
Exception in thread "main" java.lang.NoClassDefFoundError: test2.class
at gnu.java.lang.MainThread.run(libgcj.so.90)
Caused by: java.lang.ClassNotFoundException: test2.class not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:./], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
at java.net.URLClassLoader.findClass(libgcj.so.90)
at gnu.gcj.runtime.SystemClassLoader.findClass(libgcj.so.90)
at java.lang.ClassLoader.loadClass(libgcj.so.90)
at java.lang.ClassLoader.loadClass(libgcj.so.90)
at gnu.java.lang.MainThread.run(libgcj.so.90)
Probably the weirdest thing about this error is the fact that I only receive it when I run it via the terminal. If I run it via my IDE (Eclipse), I get no error! What's the deal here?
By the way, he is my code:
public class test2 {
public static void main(String[] args) {
Hello h = new Hello();
h.hi();
}
}
class Hello {
void hi() {
System.out.println("Hello");
}
}
Thank you very much in advance.