简体   繁体   中英

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. When I'm double clicking that Jar file, programs runs with javaw which is not showing me output in console ie in command window

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. Please help me for this issue.

The jar file built has nothing to do with java or javaw when you double click it. Your machine is set to use javaw when running a jar .

To use java just run it from a command line:

java -jar myjar.jar

To run it via command line, you could always make a batch script to launch the jar.

On double click it will run with javaw by default. Better way to do so is make the Jar file and then convert it to .exe file with Launch4J with below settings,

  1. In Basic tab - Specify Output.exe filename.
  2. In Basic tab - Set the jar file location.
  3. In JRE tab specify the minimum JRE version.
  4. In Header tab - Change Header type to console instead of 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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