Java Tool Tutorials - Herong's Tutorial Notes
Dr. Herong Yang, Version 5.00

'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 application with "java" in a command window, JVM will use that command window as the console. If you launch a Java application 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 application. "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. Go to Start > Run, type "java -classpath c:\herong ShowMemory", and click OK.

3. You should see a command window showing up displaying the program output. "java" tool created this window as the console.

4. Go to Start > Run, type "javaw -classpath c:\herong ShowMemory", and click OK.

5. You should see no command window showing up. But what happens to my program? Is it still running?

6. Go to Start > Run, type "taskmgr", and click OK. 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 application, no console window will be created and data sent to the standard output stream will not be displayed. So "javaw" is good tool for applications that do not need the console window, like GUI applications and server applications.

Sections in This Chapter

'java' - Java Launching Command and Options

Launching Hello.java - My First Java Program

Option "-classpath" - Specifying Class Path

Option '-jar' - Specifying Executable JAR Files

Option '-X' - Specifying Non-Standard Options

'javaw' - Launching Java Programs without Console

Dr. Herong Yang, updated in 2008
'javaw' - Launching Java Programs without Console