0

The exact error I'm getting is :

Error: Unable to load class "MainClass" due to exception: java.lang.NoClassDefFoundError: MainClass (wrong name: thiagodnf/sootparser/example/grocery/MainClass

Included is the Zip of the class files, which I have located in a file path of:

C:\Eclipse\Workspaces\Refactor\sootparser-master\sootparser-example-grocery\target\classes\thiagodnf\sootparser\example\grocery

The class files can be found at this link:

There are a bunch of them in their own folders, so if there is a better way to share than a Gdrive link let me know. The folder on the link is called "grocery" it should be placed as the folder at the end of the file path ( it's not /grocery/grocery)

The command I am attempting to run is: C:\Eclipse\randoop> java -Xmx3000m -classpath C:\Eclipse\Workspaces\Refactor\soot parser-master\sootparser-example-grocery\target\classes\thiagodnf\sootparser\exa mple\grocery;C:/Eclipse/randoop/randoop-all-4.1.1.jar randoop.main.Main gentests --testclass=MainClass

The source code is stored at this path:

C:\Eclipse\Workspaces\Refactor\sootparser-master\sootparser-example-grocery\src\main\java\thiagodnf\sootparser\example\grocery

The link to the source .java files are:

I renamed the folder so it wasn't as confusing for the upload, however it's original name is "grocery" and like the above path is not nested inside (/grocery/grocery)

My java version is:

>     > java Runtime Environment (build 1.8.0_201-b09) 
>     > Java HotSpot(TM) 64-Bit
>     > Server VM (build 25.201-b09, mixed mode)version "1.8.0_201" Java(TM) SE

So far I have tried different locations and paths to target "MainClass" I have moved it out as far as the the root, and also placed it in the same directory as the randoop jar file. Randoop seems to run against some other class files on my machine, so my concern is either the "MainClass" is not formatted in a way randoop can read it, or i'm missing something with my command, or location path.

The short term I would like it to run against MainClass, in the long run i'll need to do a class file list, and run it against all the classes in the different modules.

Thanks for anything you can do to help, or point me in the correct direction. If I can provide any more information or clarification please let me know.

Thank you!!

ff210327
  • 15
  • 5
  • If MainClass is in a package, should the testclass=MainClass option include the package? – NormR Mar 24 '19 at 16:26
  • MainClass sits at the base location in "grocery", the other classes that it calls are located in sub directories from that location. Or did i miss-understand your question? – ff210327 Mar 24 '19 at 16:35
  • Does the MainClass.java file have a package statement at the top? – NormR Mar 24 '19 at 20:14
  • yes it does `package thiagodnf.sootparser.example.grocery;` What could I do to handle that if it's what's jamming randoop call? – ff210327 Mar 24 '19 at 22:17
  • Add the full package name to the class name to get the correct class name: thiagodnf.sootparser.example.grocery.MainClass – NormR Mar 25 '19 at 02:15
  • that worked!! I can't tell you how many hours I have been beating my head into this problem. Thank you so much!!!!! – ff210327 Mar 25 '19 at 11:49

1 Answers1

-1

Please see:
https://dzone.com/articles/java-classnotfoundexception-vs-noclassdeffounderro
This gives a thorough explanation of what the two exception/error states ClassNotFoundException and NoClassDefFoundError mean and the differences between the states.
Hopefully this will help resolve your issue.

In short, it looks like there is some versioning issue, whereby some class or method in a class that is being used in your code (or code used by your code) is not available to the runtime.

Bill Naylor
  • 482
  • 1
  • 9
  • 14