[英]SWT Error: Exception in thread “main” java.lang.NoClassDefFoundError: org/eclipse/swt/graphics/Device
I'm making a software using SWT. 我正在使用SWT制作软件。 I have exported it from eclipse to a JAR file using a custom Manifest file:
我已使用自定义清单文件将其从eclipse导出到JAR文件:
Manifest-Version: 1.0
Class-Path: swt.jar
Main-Class: db_hud.HUD_Maker
My Navigation menu looks something like this 我的导航菜单看起来像这样
Java Project
- bin
- src
+ db_hd
> HUD_Maker.java
> Classes.java
- Logfile.txt
- Manifest.txt
- swt.jar
- .classpath
- .project
org.eclipse.swt
-All the stuff for SWT (jar, .classpath, etc.)
I have the swt.jar in my classpath with kind lib. 我在类路径中的类路径中有swt.jar。 I tried changing the Main-Class in the manifest file to include .java in the end, it said "Main Class not found" I do not know how to reproduce this error since I don't know what is the cause of it.
我尝试将清单文件中的Main-Class最终更改为包括.java,它说“找不到Main Class”,我不知道如何重现此错误,因为我不知道是什么原因引起的。 If I did I would not be looking for a solution to this problem.
如果我没有,我不会在寻找解决这个问题的方法。
I have tried exporting it as a JAR with the manifest file, but what I get in the console is: 我尝试将其与清单文件一起导出为JAR,但是在控制台中得到的是:
Exception in thread "main" java.lang.NoClassDefFoundError:
if i just double click i get a JNI Error. 如果我只是双击我会收到一个JNI错误。 No idea what that is...
不知道那是什么...
Can anyone help me? 谁能帮我? or is this info too little?
还是此信息太少?
Export your java code to a jar file eg hudmaker.jar then put your jar and the swt.jar in a directory. 将Java代码导出到jar文件(例如hudmaker.jar),然后将jar和swt.jar放在目录中。 The swt.jar library can be downloaded from eclipse [1].
可以从eclipse [1]下载swt.jar库。 Open a command line and change to that directory.
打开命令行并转到该目录。
Then start your code like this 然后像这样启动您的代码
java.exe -Djava.library.path="." -cp "hudmaker.jar;swt.jar" db_hud.HUD_Maker
As an alternative you can create an executable jar [2]. 或者,您可以创建一个可执行jar [2]。
[1] https://www.eclipse.org/swt/ [1] https://www.eclipse.org/swt/
[2] http://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Ftasks%2Ftasks-37.htm [2] http://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Ftasks%2Ftasks-37.htm
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.