如何创建可以分发或打包的可执行jar文件? [英] How to create an executable jar file which can be distributed or packaged?
问题描述
我正在使用 getdown 创建更新Java应用程序的方法. 完成本教程后,我测试了它是否可以在命令行上运行,如下所示:
I am using getdown to create a means to update a java application. When I have completed this tutorial, I tested if it works on command line as below:
% java -jar c:/downloads/getdown-X.Y.jar c:/netBeans/getdown/src
非常感谢,它可以运行并启动该应用程序.很好.
Thankfully, this works and launches the application. Great.
我如何制作一个jar文件并分发它?
How do I make a jar file and distribute this?
我试图在此项目上创建一个jar文件,但是该文件不起作用,该项目无法运行.当我在命令行上运行此 getdown-X.Y.jar 时.
I tried to make a jar file on this project but it didn't work, this project does not run. When I run this getdown-X.Y.jar on command line.
我认为它仍然使用我在 c:/netBeans/getdown/src 之前创建的文件.最终,由于缺少jar文件,它无法执行.因此,如何使该项目成为jar文件并将其分发.
I think it still using the same file which I created before c:/netBeans/getdown/src. Eventually, it is failing to execute since it is missing the jar file. So, how to make this project into a jar file and distribute it.
推荐答案
我不确定您正在使用哪种操作系统.您可以通过创建可执行jar文件来实现.请按照此处的步骤操作:
I am not sure what OS you are working on.You can do this by creating an executable jar file. Please follow the steps here:
如果要创建包含其他文件的jar文件.在下面的内容中,如果您想创建一个带有 readme.txt
If you want to create a jar file with additional file. Here in below, if you want to create a jar file of imagine src.class with additonal text file with it which is readme.txt
c:\patel\projects\netbeans\getdown\src.class
c:\patel\projects\readme.txt
运行此命令:jar -cvfm src.jar readme.txt netbeans\getdown\*.class
,即:c:\patel\projects\jar -cvfm src.jar readme.txt netbeans\getdown\*.class
现在,您的可执行jar文件已准备就绪.要运行此jar文件:
which is: c:\patel\projects\jar -cvfm src.jar readme.txt netbeans\getdown\*.class
Now your executable jar file is ready. To run this jar file:
在命令提示符下运行此命令:java -jar src.jar
run this on command prompt: java -jar src.jar
这篇关于如何创建可以分发或打包的可执行jar文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!