简体   繁体   English

如何使用 Netbeans IDE 使用 Java 而不是 Javaw 制作 JAR 文件

[英]How to make JAR file with Java instead of Javaw using Netbeans IDE

I have made JAR file using Netbeans IDE's clean & build option.我已经使用 Netbeans IDE 的 clean & build 选项制作了 JAR 文件。 When I'm double clicking that Jar file, programs runs with javaw which is not showing me output in console ie in command window当我双击该 Jar 文件时,程序使用javaw运行,它没有在控制台中显示我的输出,即在命令窗口中

I want to make Jar file with Java.exe instead of jawaw using netbeans, which will run on double click or with windows task scheduler and display me output in command prompt.我想和JAVA.EXE Jar文件,而不是jawaw使用NetBeans,这将在双击或使用Windows任务调度程序的运行和显示我输出的命令提示符。 Please help me for this issue.请帮我解决这个问题。

The jar file built has nothing to do with java or javaw when you double click it.双击构建的jar文件与javajavaw无关。 Your machine is set to use javaw when running a jar .您的机器设置为在运行jar时使用javaw

To use java just run it from a command line:要使用java只需从命令行运行它:

java -jar myjar.jar

To run it via command line, you could always make a batch script to launch the jar.要通过命令行运行它,您总是可以制作一个批处理脚本来启动 jar。

On double click it will run with javaw by default.双击它会默认使用 javaw 运行。 Better way to do so is make the Jar file and then convert it to .exe file with Launch4J with below settings,更好的方法是制作 Jar 文件,然后使用Launch4J使用以下设置将其转换为 .exe 文件,

  1. In Basic tab - Specify Output.exe filename.在基本选项卡中 - 指定 Output.exe 文件名。
  2. In Basic tab - Set the jar file location.在基本选项卡中 - 设置 jar 文件位置。
  3. In JRE tab specify the minimum JRE version.在 JRE 选项卡中指定最低 JRE 版本。
  4. In Header tab - Change Header type to console instead of GUI.在标题选项卡中 - 将标题类型更改为控制台而不是 GUI。

And build the wrapper.并构建包装器。

4th step will sort your problem, Which will run program in console(command prompt) on running .exe file either on double click or running from Windows Task scheduler.第 4 步将对您的问题进行排序,这将在控制台(命令提示符)中运行程序,双击运行 .exe 文件或从 Windows 任务调度程序运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM