|
The computer science department at my university does all of their core courses in Java, which is good for me in some ways because I'm used to C++. However, they also insist on using Eclipse, and I don't know whether it's because my computer is six years old or because Eclipse is so damn huge, but it takes about three hours to get its context menus figured out, and thus is impossible for writing code in. Since I write everything else I do in vim and compile at the command line anyway, I'd just as soon do that with Java. So at the beginning of the summer, I downloaded and installed the latest JDK. Now, it compiles things just fine, but attempting to run the compiled programs results in this error:
Exception in thread "main" java.lang.NoClassDefFoundError: MyClass.class at gnu.java.lang.MainThread.run(libgcj.so.7) Caused by: java.lang.ClassNotFoundException: MyClass.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.7) at java.lang.ClassLoader.loadClass(libgcj.so.7) at java.lang.ClassLoader.loadClass(libgcj.so.7) at java.lang.Class.forName(libgcj.so.7) at gnu.java.lang.MainThread.run(libgcj.so.7)
Part II: I can compile junit tests with junit imports in them, by using -classpath path/to/junit/jar/file, but they encounter the same problems when I try to run them. However, my professor told me that the way I need to compile junit tests with JDK is to compile it with another file with the text:
import junit.textui.TestRunner.*;
public class RunTestMyClass { public static void main (String [] args) { junit.textui.TestRunner.run (TestMyClass.class); } }
Trying to compile this results in some error message to effect that it can't figure out what this "TestRunner" thing is, even though it seems to have figured out that it's in the junit.textui file.
Can anyone tell me how to make this work on my machine? |