If you have a JAR file and you want it to behave like a grown up program on Windows 10 you need to be sure Java is actually available and that the JAR knows how to start itself. This guide shows how to run a JAR from the command prompt using java -jar how double click behavior works and how to associate JAR files with the Java runtime so double click stops being a mystery.
Open a command prompt and run the command
java -version
If you see a version number you are golden. If the command is not found download a JDK or a reputable OpenJDK build and install it. Make sure you install a bitness that matches the JAR and any native libraries you plan to use.
Navigate to the folder that contains the JAR in File Explorer. Then type cmd
in the address bar and press Enter to open a command prompt right there. On newer Windows versions you may see an option called Open PowerShell window here or Open in Windows Terminal. Any of those work for running Java commands.
Use the standard command to launch an executable JAR
java -jar myapp.jar
Replace myapp.jar
with the actual file name. If the app prints things to the console run it this way. If it needs command line arguments just add them after the JAR name for example
java -jar myapp.jar arg1 arg2
jar tf myapp.jar
Open the META-INF backslash MANIFEST.MF entry and check for a Main-Class attribute. If there is none you either need a different JAR a wrapper or to run a class from the JAR with a classpath instead.
GUI apps sometimes use javaw to avoid leaving a command window open. If double clicking the JAR does nothing the app might require a console or it might need arguments. You can try launching with javaw to see if a GUI shows up
"path to javaw.exe" -jar myapp.jar
To make double click predictable associate the JAR extension with the Java runtime. Right click the JAR file then choose Open with then Choose another app then Browse to the Java bin folder and select javaw.exe and set Always use this app when prompted. If you need to point to the JVM you can look in the Program Files folder on your system drive and then the Java folder backslash bin subfolder to find javaw.exe.
Run java -version
to confirm Java is available. Open a command prompt in the JAR folder and run java -jar myapp.jar
. If double click does not work try javaw or associate the JAR with javaw.exe for GUI apps. If the manifest lacks a Main-Class inspect the JAR with jar tf
and get a proper executable JAR or run the application with an explicit classpath. That covers most situations so you can stop blaming Windows and start blaming your dependencies instead.
I know how you can get Azure Certified, Google Cloud Certified and AWS Certified. It's a cool certification exam simulator site called certificationexams.pro. Check it out, and tell them Cameron sent ya!
This is a dedicated watch page for a single video.