java NoClassDefFoundError org/eclipse/swt/SWTError
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11959334/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
NoClassDefFoundError org/eclipse/swt/SWTError
提问by Vihaan Verma
I m trying to compile an open source software. The build works fine and results into a jar file "five-server.jar". When I try to run this file from cmd , I get these errors.
我正在尝试编译一个开源软件。构建工作正常并生成一个 jar 文件“five-server.jar”。当我尝试从 cmd 运行此文件时,出现这些错误。
C:\Users\vickey\code\five-server\dist\main>java -jar five-server.jar
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/swt/SWTError
Caused by: java.lang.ClassNotFoundException: org.eclipse.swt.SWTError
at java.net.URLClassLoader.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: org.devtcg.five.Main. Program will exit.
any suggestion what is wrong?
有什么建议有什么问题吗?
回答by Wolfgang Fahl
The SWT Jar files are platform dependent. See http://www.jarfinder.com/index.php/java/info/org.eclipse.swt.SWTError
SWT Jar 文件依赖于平台。见http://www.jarfinder.com/index.php/java/info/org.eclipse.swt.SWTError
e.g. on Windows a suitable jar would be: org.eclipse.swt.win32.win32.x86_3.1.0.jar
例如在 Windows 上,一个合适的 jar 是:org.eclipse.swt.win32.win32.x86_3.1.0.jar
or on Mac OS X: swt-macosx-3.0m7.jar
或在 Mac OS X 上:swt-macosx-3.0m7.jar
and so on. You might run into call kinds of followup problems if you add this dependency e.g. whether you are using 32bit or 64bit libraries.
等等。如果您添加此依赖项,例如您使用的是 32 位还是 64 位库,您可能会遇到调用类型的后续问题。
It is too bad that these kind of dependency problems show up more often than not these days :-(
这些天这些依赖问题经常出现,这太糟糕了:-(
回答by Razvan
You have to set the classpath so that it includes at least the class org.eclipse.swt.SWTError or the jar containing it:
您必须设置类路径,使其至少包含类 org.eclipse.swt.SWTError 或包含它的 jar:
java -classpath path/to/jar/containing/org.eclipse.swt.SWTError -jar five-server.jar
You should also set the Main-class attribute in the manifest file in the five-server.jar
您还应该在清单文件中设置 Main-class 属性 five-server.jar
回答by MrMins
Following the @Wolfgang Fahl answer, you might download the references here:
按照@Wolfgang Fahl 的回答,您可以在此处下载参考资料:
Standard Widget Toolkit ? 4.3 x86
标准小部件工具包 ? 4.3 x86
Maven reference: https://mvnrepository.com/artifact/org.eclipse.swt.org.eclipse.swt.win32.win32.x86.4.3.swt/org.eclipse.swt.win32.win32.x86/4.3
Maven 参考:https: //mvnrepository.com/artifact/org.eclipse.swt.org.eclipse.swt.win32.win32.x86.4.3.swt/org.eclipse.swt.win32.win32.x86/4.3
Jar 文件:http: //central.maven.org/maven2/org/eclipse/swt/org/eclipse/swt/win32/win32/x86_64/4/3/swt/org.eclipse.swt.win32.win32.x86_64 /4.3/org.eclipse.swt.win32.win32.x86_64-4.3.jar
Standard Widget Toolkit ? 4.3 x64
标准小部件工具包 ? 4.3 x64
Maven reference: https://mvnrepository.com/artifact/org.eclipse.swt.org.eclipse.swt.win32.win32.x86_64.4.3.swt/org.eclipse.swt.win32.win32.x86_64/4.3
Maven 参考:https: //mvnrepository.com/artifact/org.eclipse.swt.org.eclipse.swt.win32.win32.x86_64.4.3.swt/org.eclipse.swt.win32.win32.x86_64/4.3
Jar 文件:http: //central.maven.org/maven2/org/eclipse/swt/org/eclipse/swt/win32/win32/x86_64/4/3/swt/org.eclipse.swt.win32.win32.x86_64 /4.3/org.eclipse.swt.win32.win32.x86_64-4.3.jar