How to Run JAR Files on Windows: 5 Easy Ways
In this article
This guide shows you how to run JAR (Java Archive) files on Windows 10 and 11. You'll learn the quickest method (double-clicking), how to run JARs from the Command Prompt for more control, and what to do when nothing happens after you double-click. Before you start, make sure you have Java installed—most JAR files won't run without it.
What You'll Need
- A Windows PC (Windows 10 or 11).
- Java Runtime Environment (JRE) or Java Development Kit (JDK) installed. You can download the latest version from the official Oracle website or use a package manager like Chocolatey.
- The JAR file you want to run. Make sure it's not corrupted and that you know its location on your computer.
Step-by-Step
Method 1: Double-Click (Easiest)
- Locate the JAR file in File Explorer.
- Double-click the file. If Java is correctly installed and associated with JAR files, it should open in a new window (often a GUI application).
- If double-clicking does nothing, or opens a text editor, proceed to Method 2 or 3.
Method 2: Run from Command Prompt (More Control)
- Press Win + R, type
cmd, and press Enter to open the Command Prompt. - Navigate to the folder containing your JAR file using the
cdcommand. For example, if your file is inC:\Downloads, typecd C:\Downloadsand press Enter. - Type the following command and press Enter:
Replacejava -jar yourfile.jaryourfile.jarwith the actual filename. - If the program is a GUI application, a window should appear. If it's a console application, you'll see output in the Command Prompt window.
Method 3: Create a Batch File (For Frequent Use)
- Open Notepad (or any text editor).
- Type the following line:
Replace the path with the full path to your JAR file.java -jar "C:\path\to\yourfile.jar" - Save the file with a
.batextension, for examplerunmyapp.bat. Make sure "Save as type" is set to "All Files" to avoid saving as a .txt file. - Double-click the .bat file to run your JAR.
Method 4: Check File Association (If Double-Click Fails)
- Right-click the JAR file and select Open with > Choose another app.
- Scroll down and select Java(TM) Platform SE binary. If you don't see it, click More apps and then Look for another app on this PC.
- Browse to your Java installation folder (usually
C:\Program Files\Java\jre-version\bin\javaw.exe). Selectjavaw.exeand click Open. - Check the box "Always use this app to open .jar files" and click OK.
Method 5: Use Java Web Start (For Legacy JNLP Files)
- If your file has a
.jnlpextension (Java Web Start), you'll need to run it withjavaws. Open Command Prompt and type:javaws yourfile.jnlp - Note: Java Web Start is deprecated and may not work on newer Java versions. Most modern JARs are standalone.
Common Mistakes
- Not having Java installed: The most common reason a JAR won't run is that Java isn't installed. Verify by typing
java -versionin Command Prompt. If you get an error, install the latest JRE. - Using the wrong command: Forgetting the
-jarflag or usingjavainstead ofjavaw(for GUI apps) can cause errors. Always usejava -jarfor executable JARs. - Corrupted or incomplete JAR file: If the file was downloaded partially, it won't run. Try re-downloading it from the source.
- File association hijacked: Sometimes .jar files open with WinRAR or 7-Zip instead of Java. You need to change the default program (see Method 4).
Tips
- Use the full path: When running from Command Prompt, always use the full path to the JAR file if you're not in the same directory, or navigate to the folder first.
- Check for a manifest: An executable JAR must have a
Main-Classentry in itsMANIFEST.MFfile. If it doesn't, you'll get an error like "no main manifest attribute". You can inspect it with a ZIP tool. - Allocate more memory: For large applications, you can increase heap size with
java -Xmx1024m -jar yourfile.jar(sets max memory to 1GB). - Keep Java updated: Outdated Java versions can cause compatibility issues. Always use the latest stable release.
Troubleshooting
Double-click does nothing
- Check if Java is installed (see above).
- Right-click the file and choose "Open with" to manually select Java.
- If that doesn't work, run from Command Prompt to see the error message.
Error: "Java is not recognized as an internal or external command"
- Java is not installed or not in your PATH. Reinstall Java and ensure the
binfolder is added to your system PATH during installation.
Error: "Unable to access jarfile"
- You may have typed the filename incorrectly or the path is wrong. Use the full path and check the spelling.
Error: "no main manifest attribute"
- The JAR is not an executable JAR—it's a library. You cannot run it directly. You need to compile and run the main class manually, or find a different file.
The JAR opens but immediately closes
- This often happens with console apps. Run it from Command Prompt to see the output and any error messages.
Frequently Asked Questions
Q: Can I run a JAR file without Java installed?
No. JAR files are Java bytecode and require a Java Virtual Machine (JVM) to run. You must have the JRE or JDK installed.
Q: Why does my JAR file open with WinRAR instead of running?
WinRAR and other archive tools often associate with .jar files because they are ZIP-based. You need to change the default program to Java (see Method 4).
Q: What's the difference between java and javaw?
java runs console applications and shows output in the terminal. javaw runs GUI applications without a console window. For most GUI JARs, you can use javaw -jar to avoid an extra command prompt window.
Q: How do I know if a JAR file is executable?
Check the manifest file inside the JAR. If it contains a Main-Class attribute, it's executable. You can also try running java -jar and see if it gives an error.
Q: Can I run a JAR file on Windows 11?
Yes, Windows 11 supports JAR files just like Windows 10, as long as Java is installed.
Q: Is it safe to run any JAR file?
JAR files can contain malicious code, just like any executable. Only run JARs from trusted sources. Scan them with antivirus software before running.