Similarity: Both are Java virtual machines, used to execute Java programs
Difference: javaw.exe will not output console information when running the program. If you double-click to open the jar file (assuming that the opening method has been set), then the console window will not appear at all. It is mainly used to run programs with forms. Application, the "w" in it means window, so although it will not report an error when running a console program, it will not output any results. There is no problem whether java.exe runs a console program or a form program.
Scenario simulation one:
Write the simplest console program:
Copy the code code as follows:
public static void main(String[] args){
System.out.println("Hello World!");
}
run:
Scenario simulation two:
If you are running a program with a GUI:
1. If you use cmd to open a jar file and there is System.out.println code, java.exe will output normally, but javaw.exe will not output, but the console window will not disappear.
2. If you run the jar file through "right-click" --> "Open with", then opening the file with java.exe will retain a console window, but javaw.exe will not appear, so running a form program is generally Both use javaw.exe.
Examples of using java.exe or javaw.exe:
java [-options] class [args...]
(Used to execute a compiled bytecode file)
or java [-options] -jar jarfile [args...]
(used to execute a packaged jar file)