如何在java中制作一个独立的应用程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18742026/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to make a standalone application in java
提问by user2768759
I use eclipse to run my java code, but I want to make an application that won't use eclipse to run. I want to make it work as a portable stand alone application that only uses the libraries I need.
我使用 eclipse 来运行我的 java 代码,但我想制作一个不会使用 eclipse 运行的应用程序。我想让它作为一个可移植的独立应用程序工作,它只使用我需要的库。
回答by Raistlin
Right click on Projectfolder (in Eclipse) -> Export -> Java -> runnable JAR -> choose class with main method. Done ;)
右键单击 Projectfolder(在 Eclipse 中)-> 导出 -> Java -> 可运行 JAR -> 选择带有 main 方法的类。完毕 ;)
回答by Robert English
I'm going to assume you mean to create a .exefile. for this you'll need a .jarfile.
我将假设您的意思是创建一个.exe文件。为此,您需要一个.jar文件。
I'm not familiar with Eclipse I know that Netbeans makes the .jar file automatically once the code is compiled.
我不熟悉 Eclipse 我知道 Netbeans 会在编译代码后自动生成 .jar 文件。
(For Netbeans) This .jar file can be found in the distfolder. In case there is none see hereto fix that.
(对于 Netbeans)这个 .jar 文件可以在dist文件夹中找到。如果没有看到here来解决这个问题。
In case Eclipse puts into a different folder I'd just look in all the folders related to the project until you find a file with a .jar extension.
如果 Eclipse 放入不同的文件夹,我只会查看与项目相关的所有文件夹,直到找到扩展名为 .jar 的文件。
Once you have the .jarfile you'll need to run an application to change it from .jarto .exe, I would recommend Launch4j.
获得.jar文件后,您需要运行一个应用程序将其从.jar更改为.exe,我建议使用Launch4j。
Here'sa handy tutorial to help you with that application if you get stuck.
如果您遇到困难,这里有一个方便的教程可以帮助您使用该应用程序。
I know this isn't exactlythe answer you're looking for but it's close! Hope this helps!
我知道这是不是正是你要找的答案,但已经很接近了!希望这可以帮助!

