eclipse 项目发布
有时候需要将 j2se 工程导出,这样可以在别处运作,就不必拘泥于开发感觉中
才能运行了。
具体做法如下:
方法一:(工程没有引用外部 jar 包时,直接导出)
选中工程---->右键,Export...--->Java--->JAR le--->next-->选择 jar le
的路径及名称-->next-->next---> 选择 main class--->nish.
方法 2:
当工程引用了其他的外部 jar 时,由于 eclipse 不支持同时导出外部 jar 包的功
能,所以比较麻烦一点;具体步骤如下:
生成 manifest le:选中工程--->右键,Export--->Java--->JAR le--->选择
jar le 的路径及名称--->next--->next--->next;
此时来到了方法 1 中要选择 main class 的窗口,但这里先不选择 main
class,选择最上方的 Generate the manifest le, 勾上 Save the
manifest in the workspace,在 Manifest le:中输入 le 的名称,
如/testProject/main,(其中 testProject 为工程名,main 为 manifest le 的
名称)点击 nish,回到工程,打开刚刚生成的 main,在这里要输入如下信息:
Manifest-Version: 1.0
Main-Class:
com.pacong.convert.auto.propertes.ConvertAutoProperties
Class-Path: jxl.jar
其中,Manifest-Version: 1.0 为刚刚自动生成的 manifest 版本号;
Main-Class:
com.pacong.convert.auto.propertes.ConvertAutoProperties 为 main
class 所在类;
Class-Path: jxl.jar 为外部 jar 包名称,这里是告诉导出的 jar 包,所要用到的
外部的 jar 包的路径及名称。
上面都做完了就可以导出带外部 jar 包的 jar 包了,步骤如下:
选中工程--->右键,Export--->Java--->JAR le--->选择 jar le 的路径及名
称--->next--->next--->next,这时又来到了选择 main class 的窗口,但这
里也不选择 main class,选择 Use existing manifest from workspace,
在 Manifest le:里选择刚刚生成的 main,如:/testProject/main,点击
nish,到此就大功告成啦;假设生成的 jar 包的名称为 test.jar,那么 Class-
Path 中引入的 jxl.jar 要和 test.jar 位于同一个目录下。
Manifest-Version: 1.0
评论7