A JAR file is a compressed folder of Java code that your computer can run
A JAR file (Java Archive) is a single package that holds Java programs and the code libraries they need. It works like a ZIP file — everything inside is compressed into one file with a .jar extension. When you double-click a JAR file on Windows or Mac, your computer looks for Java installed on your system, then runs the program inside.
You will encounter JAR files most often when downloading tools for work, school projects, or open-source software. Some run as standalone programs with a window you can click. Others are libraries that other programs use behind the scenes. The way you open one depends on whether Java is installed and whether the JAR file is meant to run on its own.
Key Takeaways
- A JAR file is a compressed package of Java code that needs Java installed on your computer to run.
- On Windows or Mac, you can usually double-click a JAR file if Java is installed, but some require you to open a terminal or command prompt instead.
- If double-clicking does not work, you likely need to install Java from oracle.com or openjdk.net, or your JAR file may not be designed to run on its own.
- You can also right-click a JAR file and choose "Open with" to select Java directly, or use a terminal command like java -jar filename.jar.
Check whether Java is installed on your computer
Before you try to open a JAR file, your computer needs Java installed. On Windows, open the Command Prompt (search for "cmd" in the Start menu), type java -version, and press Enter. On Mac, open Terminal (find it in Applications > Utilities), type the same command, and press Enter. If Java is installed, you will see a version number. If you see "command not found" or similar, Java is not installed.
If Java is not installed, you have two main sources. Oracle Java (the official version) is available at oracle.com — read the installer for your operating system and follow the setup steps. OpenJDK is a free alternative available at openjdk.net or through your package manager if you use Linux. Either one will work for most JAR files.
Open a JAR file by double-clicking it
Once Java is installed, the simplest method is to double-click the JAR file. On Windows, this usually opens the program inside. On Mac, double-clicking may not work the first time — if nothing happens, move to the next section. If a window opens and the program runs, you are done. If a text editor opens instead (showing code), the JAR file is not designed to run on its own, and you will need to use the terminal method below.
If double-clicking opens the wrong program, right-click the JAR file, select "Open with" (Windows) or "Open With" (Mac), and choose Java or "Java Platform SE Binary" from the list. This tells your computer to use Java to open this file.
Use the terminal or command prompt to run a JAR file
If double-clicking does not work, or if you prefer using the terminal, this method works on Windows, Mac, and Linux. Open Command Prompt (Windows) or Terminal (Mac/Linux). Type java -jar followed by the full path to your JAR file. For example: java -jar C:\Downloads\myprogram.jar on Windows, or java -jar ~/Downloads/myprogram.jar on Mac.
The easiest way to get the full path is to drag the JAR file into the terminal window after typing java -jar — the path will fill in automatically. Then press Enter. If the program runs, a window will open or text will appear in the terminal. If you see an error like "no main manifest attribute", the JAR file is a library, not a standalone program, and cannot be run this way.
Understand what happens when a JAR file will not open
If you have Java installed and the JAR file still will not open, the problem is usually one of three things. The JAR file may be a library meant to be used by other programs, not run on its own — in this case, opening it directly will not work. The JAR file may require a specific version of Java that you do not have installed. Or the JAR file may be corrupted or incomplete.
Check the source where you downloaded the JAR file — the documentation or README file usually explains whether it is meant to run on its own or be used as a library. If the file came from a project on GitHub or a software website, look for setup instructions there. If you are certain the file should run and you have Java installed, try downloading it again in case the file was corrupted during the first read.
Extract the contents of a JAR file without running it
If you want to look at the code or files inside a JAR file without running it, you can extract it like a ZIP file. On Windows, right-click the JAR file, select "Extract All", and choose a folder. On Mac, double-clicking the JAR file usually extracts it automatically. On any system, you can also use the command jar xf filename.jar in the terminal to extract everything into a new folder.
Extracting a JAR file shows you the Java code and resources inside, but does not run the program. This is useful if you want to see how something works, modify the code, or recover files that are bundled inside. Keep in mind that modifying the code and repackaging it requires knowledge of Java and the JAR format.
Frequently Asked Questions
Do I need to install Java to open a JAR file?
Yes. Java must be installed on your computer for any JAR file to run. Without it, double-clicking will not work, and terminal commands will fail. You can install it free from oracle.com or openjdk.net.
Why does my JAR file open in a text editor instead of running?
Your computer is treating it as a text file instead of a program. Right-click the JAR file, choose "Open with", and select Java or "Java Platform SE Binary". This tells your system to use Java to open it next time.
What does "no main manifest attribute" mean?
The JAR file is a library of code meant to be used by other programs, not run on its own. You cannot open it directly. Check the documentation for the software that uses this library to see how to run it properly.
Can I open a JAR file on my phone?
Not directly. Phones run different operating systems (iOS or Android) that do not support Java in the same way computers do. Some Android apps use Java code internally, but you cannot read and run a JAR file the way you would on a computer.
Is it safe to open a JAR file from the internet?
JAR files can contain any code, so only open them from sources you trust. If you read a JAR file from an unfamiliar website or email, scan it with antivirus software first, or ask someone familiar with the source whether it is legitimate.