This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Grokking Bitcoin and have Kalle Rosenbaum on-line!
See this thread for details.
Win a copy of Grokking Bitcoin this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
Bartenders:
  • Carey Brown
  • salvin francis
  • Claude Moore

Running Javaflow  RSS feed

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everyone,

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?

I download the commons-javaflow-2006.jar and asm-3.3.jar and try to test it with the example on Apache: http://commons.apache.org/sandbox/javaflow/tutorial.html
This is the code:



I write build.xml like this:



Below is the output:


Buildfile: build.xml

clean:

build:
[javac] Compiling 1 source file to /home/lihao/Desktop/JavaflowTest/class
[javaflow] Rewriting /home/lihao/Desktop/JavaflowTest/class/MyRunnable.class

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.
 
Marshal
Posts: 64157
215
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How did you set the CLASSPATH?
 
puff li
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:How did you set the CLASSPATH?



Thanks for reply~

In build.xml:





Is it right?
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd assume the classname needs to be fully qualified.
 
Campbell Ritchie
Marshal
Posts: 64157
215
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

David Newton wrote:I'd assume the classname needs to be fully qualified.



What do you mean by fully qualified?
 
puff li
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Marshal
Posts: 64157
215
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
The harder you work, the luckier you get. This tiny ad brings luck - just not good luck or bad luck.
Create Edit Print & Convert PDF Using Free API with Java
https://coderanch.com/wiki/703735/Create-Convert-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!