javaw - Launching Java Programs without Console

This section provides a tutorial example on how to use 'javaw' tool to launch a Java program without the output console window.

If you launch a Java program with "java" in a command window, JVM will use that command window as the console. If you launch a Java program with "java" in a different way, "java" will create new command window and use it as the console.

If you don't want console, you can user "javaw" launch your program. "javaw" works exactly like "java" except that it will not create any console.

Here is what I did to test the "javaw" tool.

1. Compile ShowMemory.java and copy ShowMemory.class to c:\herong.

2. Open a command window and run "java -classpath c:\herong ShowMemory".

3. You should see the program output displayed in the same window. The Windows command prompt is not showing any more. "java" tool is using this window as the console.

4. Open another command window and run "javaw -classpath c:\herong ShowMemory".

5. You should see no program output in the window. The Windows command prompt is showing to take any new commands. But what happens to my program? Is it still running?

6. Run "Task Manager". The Windows Task Manager windows shows up.

7. Go to "Process" tab, you should see two Java processes: "java" and "javaw". This answers my previous question. "javaw" is still running ShowMemory without any console as expected.

Through this tutorial, we should remember that when you use "javaw" to launch an program, no console window will be created and data sent to the standard output stream will not be displayed. So "javaw" is good tool for programs that do not need the console window, like GUI applications and server applications.

Last update: 2018.

Table of Contents

 About This Book

 Java Tools Terminology

 Java Tools Included in JDK

 javac - The Java Program Compiler

 jar - The JAR File Tool

 jlink - The JRE Linker

 jmod - The JMOD File Tool

 jimage - The JIMAGE File Tool

java - The Java Program Launcher

 java - Program Launching Command and Options

 Launching Hello.java - My First Java Program

 "java -classpath" - Specifying Class Path

 "java -jar" - Specifying Executable JAR File

 "java -X" - Specifying Non-Standard Options

 "java --list-modules" - Listing Modules in JDK

 "java --describe-module" - Printing Module Definition

 "java --module" - Launching Program from Module

 "java --module" - Launching Program from Module JAR

javaw - Launching Java Programs without Console

 jdb - The Java Debugger

 jcmd - The JVM Diagnostic Tool

 jconsole - Java Monitoring and Management Console

 jstat - JVM Statistics Monitoring Tool

 JVM Troubleshooting Tools

 jvisualvm (Java VisualVM) - JVM Visual Tool

 jmc - Java Mission Control

 javap - The Java Class File Disassembler

 keytool - Public Key Certificate Tool

 jarsigner - JAR File Signer

 jshell - Java Language Shell

 native2ascii - Native-to-ASCII Encoding Converter

 Outdated Tutorials

 References

 Full Version in PDF/EPUB