如何使用Eclipse创建一个自定义的.jar文件? [英] How can I create a self-consistent .jar file with Eclipse?

查看:170
本文介绍了如何使用Eclipse创建一个自定义的.jar文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Eclipse中编写了我的Java应用程序。现在我想生成一个.jar文件,可以在命令行的其他系统上运行。在Eclipse中有一个简单的方法吗?



我特别想知道我应该怎么用我使用的外部库的jar文件(应该包括在内)另外我应该生成一些清单文件吗?



ADDED:



我看到我可以选择将需要的库解压缩到生成的JAR或将需要的库转换为生成的JAR等窗口。我选择第一个选项,我指定导出目的地,但下一步按钮尚未激活。还应该指定什么我被提议启动一个配置,但我不想。每个配置与命令行中给定的一组固定参数相关联,我不希望这样。

解决方案

选择项目,然后导出 => Java => Runnable JAR文件



然后,您可以选择将所需的库解压缩/打包/复制到JAR中,并选择该类,其 main()方法应该在启动时执行。



然后,您可以通过以下方式执行生成的jar:
java -jar yourjar.jar


I wrote my Java application in Eclipse. Now I would like to generate a .jar file which can be run on other systems from the command line. Is there a easy way to do it in Eclipse?

In particular I am wondering what should I do with the jar files of external library that I use (should it be included into my .jar file?).

Moreover, should I generate some manifest files?

ADDED:

I see the window in which I can choose "Extract required libraries into generated JAR" or "Package required libraries into generated JAR" and so on. I select the first option, I specify export destination but "Next" button is not activated yet. What else should I specify. I am offered to launch a configuration but i do not want to. Every configuration is associated with a fixed set of parameters given in the command line and I do not want that.

解决方案

Select you project, then Export => Java => Runnable JAR file

You can then choose to extract/package/copy required libraries into your JAR and also select the class, whose main() method should be executed on startup.

Then you can execute the generated jar via: java -jar yourjar.jar

这篇关于如何使用Eclipse创建一个自定义的.jar文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆