Java 如何在清单文件中设置类路径,同时从 Eclipse 创建 JAR?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2636078/
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
How to set classpath in manifest file , while creating JAR from eclipse?
提问by Hippo
I am trying to creat JAR file through eclipse. I read some of the threads from
stackoverflow as well as other forums. But nothing is helping.
stackoverflow 以及其他论坛。但没有任何帮助。
I have created a separate manifest file like this one.
我创建了一个像这样的单独清单文件。
Manifest-Version: 1.0
Main-Class: Main
Class-Path: gnujaxp.jar iText-2.1.5.jar jcalendar.jar jcommon-1.0.16.jar jfreechart-1.0.13.jar jfreechart-1.0.13-experimental.jar jfreechart-1.0.13-swt.jar junit.jar servlet.jar swtgraphics2d.jar tinyos.jar
I have put all this jars in same project folder.
我已将所有这些罐子放在同一个项目文件夹中。
While exporting i am exporting all resources (meants this jar files also.)
导出时我正在导出所有资源(也意味着这个 jar 文件。)
But still i am getting noclassdeffound error when my application tries to load any one of the jar included.
但是当我的应用程序尝试加载包含的任何一个 jar 时,我仍然收到 noclassdeffound 错误。
M i wrong anywhere ..
我哪里都错了..
Thanks in advance.
提前致谢。
回答by Jean
If you are using eclipse >=3.4 try "export as runnable jar file" it should generate it correctly.
如果您使用的是 eclipse >=3.4,请尝试“导出为可运行的 jar 文件”,它应该会正确生成它。
Otherwhise you can provide your own manifest file in the export as jar dialog.
否则,您可以在导出为 jar 对话框中提供您自己的清单文件。
回答by Mary C
I get this error and find that my manifest
needs a space after the jars in the class-path
. This includes the ones at the end of the line and end of list, otherwise it mashes them together.
我收到此错误,并发现我manifest
需要在 .jar 文件后留一个空格class-path
。这包括行尾和列表末尾的那些,否则会将它们混在一起。
回答by pHneutre
Be sure to add an empty line at the end of your Manifest file.
请务必在清单文件的末尾添加一个空行。