简体   繁体   English

即使该类存在于jar文件中,也会引发java.lang.ClassNotFoundException

[英]Throwing java.lang.ClassNotFoundException even if the class exists in jar file

I cannot understand why this error occurs when I am running the jar file: 我无法理解为什么在运行jar文件时会发生此错误:

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 线程“主”中的异常java.lang.NoClassDefFoundError:net / sf.mzmine.main.MZmineCore.main(MZmineCore.java:100)上的net / sf / mzmine / main / MZ mineModulesList造成原因:java.lang.ClassNotFoundException: net.sf.mzmine.main.MZmineModulesList

It says that MZmineModulesList class is not found but it exists in this path. 它说未找到MZmineModulesList类,但它存在于此路径中。 Maybe I did something wrong when I was writing classes to the jar file? 在将类写入jar文件时,也许做错了什么?

I wanted to add that this appeared after I replaces MZmineModuleList file with updated version. 我想补充一点,这是在我用更新的版本替换MZmineModuleList文件之后出现的。 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. 我做了什么:我从Jar中提取了文件并添加了新类,并且还用旧的MZmineModuleList类代替了新的类,在其中添加了几行代码。 Maybe when I am writing to the jar file using the method of java.util.jar I missed something? 也许当我使用java.util.jar的方法写入jar文件时,我错过了一些东西吗?

如果类的静态代码块中有错误,则可能会发生NoClassDefFoundError

The class may be abigious. 上课可能有点矛盾。 If a class can be loaded from more than one classloader this error may be thrown, too. 如果可以从多个类加载器中加载一个类,则也可能引发此错误。

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. 如果您使用的是IDE或其他方式为您构建所有内容,请检查并确保它包含jar中的所有类。 I've seen the Eclipse IDE export jars without all of the class files included. 我已经看到了不包含所有类文件的Eclipse IDE导出jar。 If that is the case, just put the class file in the jar. 如果是这种情况,只需将类文件放入jar中即可。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从jar文件加载类时出现java.lang.ClassNotFoundException - java.lang.ClassNotFoundException when loading a class from a jar file Class 存在但显示“java.lang.ClassNotFoundException” - Class exists but says “java.lang.ClassNotFoundException” 带jar文件的Crontab java.lang.ClassNotFoundException - Crontab java.lang.ClassNotFoundException with a jar file 在TestNG中运行时,即使对于内置类型,使用反射创建类也会引发java.lang.ClassNotFoundException - Using reflection to create a class is throwing java.lang.ClassNotFoundException even for builtin types when running in TestNG 当 class 在路径中时,Servlet 抛出 java.lang.ClassNotFoundException - Servlet Throwing java.lang.ClassNotFoundException when class in path weblogic ADF中的固定/非理性java.lang.ClassNotFoundException,JAR中的类 - Stubborn/irrational java.lang.ClassNotFoundException in weblogic ADF, class in JAR 从罐子内部执行类文件时出现java.lang.ClassNotFoundException - java.lang.ClassNotFoundException while executing a class file from inside a jar java.lang.ClassNotFoundException抛出一些错误 - java.lang.ClassNotFoundException throwing some error 运行 jar 文件返回错误:Error: Could not find or load main class MyClass Caused by: java.lang.ClassNotFoundException: MyClass - Running jar file returns error: Error: Could not find or load main class MyClass Caused by: java.lang.ClassNotFoundException: MyClass Android.mk jar文件导入java.lang.Error:包装失败:java.lang.ClassNotFoundException - Android.mk jar file import java.lang.Error: packaging failure: java.lang.ClassNotFoundException
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM