The difference between java, javaw and javaws:
First of all, all of these are java startup devices. java.exe is often used. When using the command line to output to the window, there will be a java.exe process, which can be seen through the task manager. Usually when we execute some small java programs, the java.exe process will be running. javaw.exe is also special to us. We can also see the running of the javaw.exe process through the task manager. javaws is usually the process when the web is started.
jvm.dll
jvm.dll is the implementation of a java virtual machine on the windows platform environment and is also part of the JRE. A C program can run directly on the jvm using jvm.dll.
java.exe
java.exe is a win32 console application. It provides a help instead of using jvm.dll to execute java classes files. As a win32 console application, it is obviously associated with a console. When executing java classes, It runs.
javaw.exe
javaw.exe is similar to java.exe and is a win32 GUI application. The application provides its own GUI window and does not enable the console.
Therefore we want to run a GUI program without requiring a command console.
Here is an example:
Copy the code code as follows:
package javaw;
import javax.swing.*;
public class HelloWorldSwing {
private static void createAndShowGUI() {
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() {
createAndShowGUI();
}
});
}
}
The above is a GUI program. To run it as follows is to run it on the console:
Copy the code code as follows:
java -classpath .javaw.HelloWorldSwing
Explanation: -classpath . means setting the classpath path to the current directory.
After running, check the task manager and the java.exe process appears ------ because it is run through the console.
The picture is as follows:
If you run it directly in eclipse: After running, check the task manager to see the javaw.exe process - because it is not run through the console output.
The picture is as follows:
If you use javaw to run it through the command line, it is also as shown in the figure above:
Note:
The process started by javaw -classpath . javaw.HelloWorldSwing is javaw.exe
The process started by java -classpath . javaw.HelloWorldSwing is java.exe
Another difference between the two running modes of java.exe and javaw.exe is that after java runs the GUI, it blocks there until the window is closed.
After javaw runs the GUI, you can directly run the next command.
javaws.exe
The javaws.exe process is suitable for starting programs configured through the web. In short, it is used in web applications.
Summarize:
java.exe is used to start the window console console program
javaw.exe is used to start GUI programs
javaws.exe is used for web programs.
jvm.dll is an implementation of the Java virtual machine specification on the Windows platform