I am writing a model checker and need to store and restore state of programs. After googling, I found Apache Javaflow appears to be a neat tool to do it. However, I got problem running it. Can someone kindly help?
run:
[java] Exception in thread "main" java.lang.NoClassDefFoundError: MyRunnable
[java] Caused by: java.lang.ClassNotFoundException: MyRunnable
[java] at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
[java] at java.security.AccessController.doPrivileged(Native Method)
[java] at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
[java] at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
[java] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
[java] at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
[java] at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:334)
[java] Could not find the main class: MyRunnable. Program will exit.
[java] Java Result: 1
BUILD SUCCESSFUL
Total time: 1 second
And the compilation seems fine. But when running, it turns out "Could not find the main class".
We I run the instrumented Myrunnable.class from commandline, it report error like this:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/javaflow/bytecode/Continuable
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
at java.net.URLClassLoader.access$000(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:212)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:334)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.javaflow.bytecode.Continuable
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:334)
... 12 more
Could not find the main class: MyRunnable. Program will exit.
I don't understand why. I have included every possible lib in my classpath. Please help!
Thanks.
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32708
4
posted
0
How did you set the CLASSPATH?
puff li
Greenhorn
Joined: Jul 28, 2010
Posts: 22
posted
0
Campbell Ritchie wrote:How did you set the CLASSPATH?
I'd assume the classname needs to be fully qualified.
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32708
4
posted
0
And does your classpath still include the . for current directory? If you are putting your compiled files into the "class" directory, is that in the classpath?
puff li
Greenhorn
Joined: Jul 28, 2010
Posts: 22
posted
0
David Newton wrote:I'd assume the classname needs to be fully qualified.
What do you mean by fully qualified?
puff li
Greenhorn
Joined: Jul 28, 2010
Posts: 22
posted
0
Campbell Ritchie wrote:And does your classpath still include the . for current directory? If you are putting your compiled files into the "class" directory, is that in the classpath?
Wow, it works when I add "class" directory in the classpath!
Thank you so much Campbell!!! Thank you David as well!!! I spent a whole day yesterday working on it!
So can you explain why I have to add "class" directory in the classpath. It just contains one compiled file. I specified to run it as main class in
why should I add it again? I suppose classpath means where needed libraries are located?
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32708
4
posted
0
The classpath variable tells the JVM where to look for .class files. If you have your .class files in the "class" directory, you have to instruct it to try there for .class files.