简体   繁体   中英

Java Class Path issue with Randoop

I'm using Randoop, the automatic test generator for Java.

However, when running Randoop from the commandline, I can't seem to figure out how to properly specify the classpath.

I read through this question: Java Classpath error-cannot find my class in detail but my setup seems a bit different.

I'm running on a Windows machine.

The overall project structure looks like this:

cse331/
    bin/
        hw5/
            GraphNode.class
    src/
        hw5/
            GraphNode.java
    randoop-2.1.4.jar

(There are some other files but the not important here, I think)

I tried calling:

java -ea -classpath randoop-2.1.4.jar:bin/* randoop.main.Main gentests --testclass=GraphNode --timelimit=20

But received the error:

Error: Could not find or load main class randoop.main.Main

I've tried several variations, loading in the .java file instead of the .class file for the classpath but no option has worked so far. If I don't specify the class path at the end of randoop-2.1.4, I get an error message saying the class GraphNode cannot be found.

The setup is just the first step and I can't seem to get on the right track.

Set classpath like below:

-classpath "randoop-2.1.4.jar;bin/*"

For more details see Setting the class path

最后,解决方案是从bin /中删除星号,并包括Sumit建议的半冒号。

java -ea -classpath randoop-2.1.4.jar;bin/ randoop.main.Main gentests --testclass=GraphNode --timelimit=20

Try this one: It will surely remove this error. java -cp cse331/bin;randoop-2.1.4.jar randoop.main.Main gentests --testclass=hw5.GraphNode --timelimit=100.

If your project is maven project, Try to include all dependencies. for downloading use this command: mvn dependency:copy-dependencies

Let me know if you have any other queries regarding randoop.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM