Java Tools Tutorials - Herong's Tutorial Examples - Version 6.10, by Dr. Herong Yang
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