When double clicking a .jar file a cmd window opens briefly and then disappears, but the .jar file isn't executed
Olivia Zamora
I am looking for a solution to the problem posed in the title. When I double click a .jar file, or right click and open, it simply opens a black cmd window for a split second, then closes it, and nothing else happens. I know that the programs do not run, as a few that I have tried are installers, yet the program they are meant to install are nowhere to be found. Is there a way to fix this so that the files actually function?
2 Answers
.jars are not executable files. To execute a jar, open a terminal (by Start -> Run - > type cmd (ENTER) -> cd <path-where-jar-is>) and run:
java -jar <filename.jar>No jar can execute (in Windows) by double clicking. If you want to achieve the "double clicking" effect, you will need to create a .bat or .cmd file (that is executable).
If no application shows up it is possible that the JAR file is not executable (has no main class defined) or that it has no GUI (only console output) or that it has a startup error (maybe even need more files on the classpath).
In all cases you find out more information about the actual problem if you start a command line console and execute the jar file with either
"C:\Program Files\java\jre-8\bin\java.exe" -jar file.jarIn the directory where the JAR file is stored. Of course you need to adjust the Java location to your actual location.
You can also try what happens when you „simulate“ the starting of the file:
start file.jarBTW the .jar Extension is normally registered to be opened by java to be executed. You see this in the explorer when it tells you the file type is a „Executable JAR file“. However it can happen that this association is corrupt or changed. In that case most often reinstalling JRE helps, or you manually have to clean out all other JAR associations.