0

I cannot understand why this error occurs when I am running the jar file:

Exception in thread "main" java.lang.NoClassDefFoundError: net/sf/mzmine/main/MZ mineModulesList at net.sf.mzmine.main.MZmineCore.main(MZmineCore.java:100) Caused by: java.lang.ClassNotFoundException: net.sf.mzmine.main.MZmineModulesList

It says that MZmineModulesList class is not found but it exists in this path. Maybe I did something wrong when I was writing classes to the jar file?

I wanted to add that this appeared after I replaces MZmineModuleList file with updated version. What I have done: I extracted files from Jar and added my new classes, and also instead of the old MZmineModuleList class I replaced it with new one, where several lines of codes are added. Maybe when I am writing to the jar file using the method of java.util.jar I missed something?

user1574866
  • 275
  • 2
  • 6
  • 12

3 Answers3

1

The NoClassDefFoundError can occur if there are errors in the static code blocks of the class.

Colin D
  • 5,641
  • 1
  • 23
  • 35
0

The class may be abigious. If a class can be loaded from more than one classloader this error may be thrown, too.

Christian Kuetbach
  • 15,850
  • 5
  • 43
  • 79
0

If you are using an IDE or something else to build everything for you, check to make sure that it included all the classes within the jar. I've seen the Eclipse IDE export jars without all of the class files included. If that is the case, just put the class file in the jar.

  • I am using the java code which reads all entries of the jar file and writes the files to another jar file and then I add my new updated class to this new jar file by creating new entry – user1574866 Aug 06 '12 at 17:19