First off, there are no such things as a โconsole JARโ or a โGUI JARโ. However, there are different VM launchers for console and graphic modes. Or, more precisely, there are different launchers, one of which has a console, the other does not, but both of them are capable of displaying a GUI if your program has one. These launchers are called "java" (console version) and javaw (without console version).
To start the JAR using a specific launcher, use the javaw -jar JARFILE or java -jar JARFILE command. If you launch the console version without opening the console before executing it, the console closes as soon as your program is completed. This means that if you want to see your result, you must either not interrupt your program too quickly, or simply start the console first (Win + R, "cmd", Enter) and run "java -jar ..." from the console.
Another way is to go to the Windows control panel and change the program associated with the JAR extension from "javaw" to "java". This will force every JAR in the system to use the console. For a JAR with a graphical interface, this will only lead to the inconvenience of opening another window. Sometimes this is what you want, sometimes not.
source share