The java and javaw commands states
The java and javaw tools start a Java application by starting a JRE and loading a specified class.
The javaw
command is identical to java, except that javaw
has no
associated console window. Use javaw
when you do not want a command
prompt window to be displayed.
The javaw
launcher displays a window with error information if it fails.
In case of Tomcat you won't see Win32 console application running, similarly to launch Eclipse, javaw.exe is used.
Example :
Write the following code :
import javax.swing.*;
public class JavavsJavaw {
private static void renderGUI() {
JFrame jFrame = new JFrame("HelloWorld Swing");
jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JLabel helloLabel = new JLabel("Hello World!");
jFrame.getContentPane().add(helloLabel);
jFrame.pack();
jFrame.setVisible(true);
}
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
renderGUI();
}
});
}
}
Step 1 : C:\>java JavavsJavaw
(the command-line waits for the application response till it closes)
Step 2 : C:\>javaw JavavsJavaw
(the application launches and the command line exits immediately and ready for
next command)