使用 NetBeans 从 Java 项目制作可执行文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18088607/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 22:18:43  来源:igfitidea点击:

making executable file from a java project using NetBeans

javaexecutablenetbeans6.8

提问by gandalf

i have created a java project in NetBeans. now i want to make an executable file out of it.that can be executed (run) in other computers that have JDK or JRE installed but don't have NetBeans or any other Java IDE installed.how can i do such thing using NetBeans???

我在 NetBeans 中创建了一个 java 项目。现在我想用它制作一个可执行文件。它可以在安装了 JDK 或 JRE 但没有安装 NetBeans 或任何其他 Java IDE 的其他计算机上执行(运行)。我怎样才能使用 NetBeans 做这样的事情? ??

采纳答案by Dennis Kriechel

Do you mean compile it to JAR? Netbeans does that automatically, just do clean and build(hammer sybol) and look in the distsubdirectory of your project. There will be the JAR with libfolder containing the required libraries. These JAR + lib are enough to run the application.

你的意思是编译成JAR?Netbeans 会自动执行此操作,只需执行clean and build(hammer sybol) 并查看dist项目的子目录即可。将有lib包含所需库的文件夹的 JAR 。这些 JAR + lib 足以运行应用程序。

Maby you unchecked an option:

Maby 你取消了一个选项:

Project Properties -> Build -> Packaging -> Build JAR after compiling

Project Properties -> Build -> Packaging -> Build JAR after compiling

(but this is enabled by default)

(但这是默认启用的)

回答by Sascha M

You have to build your project. Just click on the hammer in the toolbar. After that there should be a folder in your project called "dist".

你必须建立你的项目。只需单击工具栏中的锤子。之后,您的项目中应该有一个名为“dist”的文件夹。

In it is the *.jar File, which you can deploy to anybody who has Java installed.

其中是 *.jar 文件,您可以将其部署到任何安装了 Java 的人。

回答by Ajay Bhojak

you mean executable jar file. which can be executed using $java -jar myJar.jar . So you need to change manifest file inside jar. Second if you want a mouse double click execution then for Linux create .sh and for windows create .bat file containing the above specified $java -jar .

你的意思是可执行的jar文件。可以使用 $java -jar myJar.jar 执行。因此,您需要更改 jar 中的清单文件。其次,如果您想要鼠标双击执行,那么对于 Linux 创建 .sh 和对于 Windows 创建 .bat 文件,其中包含上面指定的 $java -jar 。

JVM installation is required to do so on whichever machine you want to execute.

在您要执行的任何机器上都需要安装 JVM。

Click Me :-)

点击我:-)