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

'java' - The Java Launcher

Part:   1  2  3  4  

Java Tool Tutorials

© 2006 Dr. Herong Yang

Latest updates:

  'javac' - The Java Compiler

  'java' - The Java Launcher

  'jdb' - The Java Debugger

  JAR File & 'jar' Tool

  Certificates and 'keytool'

  Installing J2SE 1.5.0

... Table of Contents

(Continued from previous part...)

"javaw" - Launching Java Applications without Console

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:\.

2. Go to Start > Run, type "java -classpath c:\temp 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:\temp 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.

Conclusions

  • "java" is the standard application launcher in JDK.
  • "-sourcepath" specifies places where to search for class definitions of new types.
  • "-jar" specifies a JAR file and launches the class specified in the manifest file.
  • "javaw" is identical to "java" except that it will not create the console window.

Part:   1  2  3  4  

Dr. Herong Yang, updated in 2006
Java Tool Tutorials - Herong's Tutorial Notes - 'java' - The Java Launcher