eclipse java 导出jar,如何从Eclipse中导出Java 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:

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

5Hr2e.png

2.Select Runnable Jar option

zYKZx.png

3.Finish the JAR creation (Here, you have the option to package all dependencies into the generated jar.)

0kFQX.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值