java - 无需 IDE 即可运行 GUI 应用程序

标签 java executable-jar

假设我使用 NetBeans 构建了一个 GUI 应用程序。要运行这个java应用程序,我需要在IDE中打开源代码然后运行。我知道我也可以通过命令提示符运行。

但是如何独立于 IDE 启动应用程序。是否有一些 .exe 文件或类似的文件,双击后可以直接运行应用程序?

如果没有,我如何生成这样的文件?

最佳答案

在这里您可以找到如何在 Netbeans 中创建 .jar:How to create a Jar file in Netbeans 您可以在每台计算机上运行可执行 jar,但有一个条件 - 系统安装了 JRE。 如果需要,您还可以使用命令行构建 .jar,为此请使用以下命令:

jar cf jar-file input-file(s)

Oracle 文档的描述:

The options and arguments used in this command are:

The c option indicates that you want to create a JAR file. The f option indicates that you want the output to go to a file rather than to stdout. jar-file is the name that you want the resulting JAR file to have. You can use any filename for a JAR file. By convention, JAR filenames are given a .jar extension, though this is not required. The input-file(s) argument is a space-separated list of one or more files that you want to include in your JAR file. The input-file(s) argument can contain the wildcard * symbol. If any of the "input-files" are directories, the contents of those directories are added to the JAR archive recursively. The c and f options can appear in either order, but there must not be any space between them.

This command will generate a compressed JAR file and place it in the current directory. The command will also generate a default manifest file for the JAR archive.

关于java - 无需 IDE 即可运行 GUI 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51803958/

相关文章:

java - 如何使用 Maven 创建具有依赖项的可执行/可运行 JAR?

java - 使用 JAVA REGEX 搜索任何给定字符串

java - 单击 JButton 后隐藏它

javascript - 如何使用 Angular 和 Java 在浏览器的另一个页面中打开预览文件(pdf、docx、txt 等)

java - 从 eclipse 导出 jar 不起作用

Java Jar 将多个 jar 组合成一个可执行 Jar

Java Eclipse 可执行 jar 文件

java - 修改执行 Jar 文件

java - 按多个字段对一组字符串、整数进行排序

java - 识别字符串中单词的第一个字符