如何使用 Eclipse 创建自洽的 .jar 文件? [英] How can I create a self-consistent .jar file with Eclipse?
问题描述
我在 Eclipse 中编写了我的 Java 应用程序.现在我想生成一个可以从命令行在其他系统上运行的 .jar 文件.在 Eclipse 中是否有一种简单的方法可以做到这一点?
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?
特别是我想知道我应该如何处理我使用的外部库的 jar 文件(它应该包含在我的 .jar 文件中吗?).
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?
添加:
我看到一个窗口,我可以在其中选择将所需的库提取到生成的 JAR 中"或将所需的库打包到生成的 JAR 中"等等.我选择第一个选项,指定导出目的地,但下一步"按钮尚未激活.我还应该指定什么.我被要求启动一个配置,但我不想.每个配置都与命令行中给出的一组固定参数相关联,我不希望那样.
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.
推荐答案
选择你的项目,然后Export
=> Java
=> Runnable JAR file
代码>
Select you project, then Export
=> Java
=> Runnable JAR file
然后您可以选择将所需的库提取/打包/复制到您的 JAR 中,并选择应该在启动时执行其 main()
方法的类.
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.
然后您可以通过以下方式执行生成的 jar:java -jar yourjar.jar
Then you can execute the generated jar via:
java -jar yourjar.jar
这篇关于如何使用 Eclipse 创建自洽的 .jar 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!