如何从Eclipse中导出Java jar,并依赖于其他jar? [英] How export Java jar from Eclipse with dependencies on other jars?
问题描述
问题是我从依赖关系中的一个类中得到一个NoClassDefFoundError。我尝试导出一个可运行的jar,其中包含所有依赖项和一个普通jar。
清单如下所示:
Manifest-Version:1.0
主类:com.path.to.MyMainClass
类路径:lib / resolver.jar lib / xercesImpl.jar lib / xml-apis.jar lib / Mac-Cocoa64 /swt.jar
.classpath如下所示:
< classpath>
< classpathentry kind =srcpath =src/>
< classpathentry kind =conpath =org.eclipse.jdt.launching.JRE_CONTAINER / org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType / JavaSE-1.6/>
< classpathentry kind =libpath =lib / resolver.jar/>
< classpathentry kind =libpath =lib / xercesImpl.jar/>
< classpathentry kind =libpath =lib / xml-apis.jar/>
< classpathentry kind =libpath =lib / Mac-Cocoa64 / swt.jar/>
< classpathentry kind =outputpath =bin/>
< / classpath>
缺少的类def来自SWT.jar文件。
任何想法可能是错误的,或者为了成功导出这个jar可以将其包含在其他地方需要采取哪些步骤?
欢呼,
Martin
可能会帮助某人
1.选择从项目属性导出
< img src =https://i.stack.imgur.com/5Hr2e.pngalt =1。选择从项目属性导出>
2.选择Runnable Jar选项
3.清理JAR创建(这里,您可以选择将所有依赖项打包到生成的jar中。)
I am trying to create a self-contained .jar file from an Eclipse project. By "self-contained" I mean that all dependenies of this project (i.e. other jars) should be included in the generated jar. I would like to use the exported jar in another project as a library. The problem is that I get a NoClassDefFoundError for one of the classes from the dependencies. I have tried exporting both a runnable jar with all dependencies packaged into it and a "normal" jar. Neither of these works.
The manifest looks like this:
Manifest-Version: 1.0
Main-Class: com.path.to.MyMainClass
Class-Path: lib/resolver.jar lib/xercesImpl.jar lib/xml-apis.jar lib/Mac-Cocoa64/swt.jar
The .classpath look like this:
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="lib" path="lib/resolver.jar"/>
<classpathentry kind="lib" path="lib/xercesImpl.jar"/>
<classpathentry kind="lib" path="lib/xml-apis.jar"/>
<classpathentry kind="lib" path="lib/Mac-Cocoa64/swt.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
The missing class def is from the SWT.jar file. Any idea what might be wrong or what steps I need to take in order to successfully export this jar so that it can be included elsewhere?
Cheers,
Martin
It may help someone
1.Select Export from Project Properties
2.Select Runnable Jar option
3.Finish the JAR creation (Here, you have the option to package all dependencies into the generated jar.)
这篇关于如何从Eclipse中导出Java jar,并依赖于其他jar?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!