A JAR file is a compressed archive that runs Java programs — you open it by double-clicking it (if Java is installed) or by typing a command in your terminal
JAR stands for Java Archive. It is a single file that bundles together all the code and resources a Java program needs to run. When you double-click a JAR file on Windows or Mac, your computer looks for Java on your system. If Java is there, it launches the program inside. If Java is not installed, nothing happens — you will see an error or the file will not open at all.
The simplest way to run a JAR file depends on whether your computer already has Java. Most people either double-click the file (the easiest route if it works) or open a terminal and type a command (the route that works when double-clicking fails).
Key Takeaways
- JAR files require Java to be installed on your computer; if double-clicking does not work, Java is probably missing.
- You can read Java for free from Oracle's website or use OpenJDK, which is also free and open-source.
- The terminal command to run a JAR file is java -jar filename.jar, typed in the folder where the file sits.
- Some JAR files need extra instructions in the command line, like java -jar filename.jar -Xmx2G to give the program more memory.
- If a JAR file is meant to run in the background (like a server), you may need to keep the terminal window open while it runs.
Check whether Java is already on your computer
Before you try to run a JAR file, learn about Java is installed. On Windows, open the Command Prompt (search for "cmd" in the Start menu). On Mac or Linux, open Terminal. Type this command and press Enter:
java -version
If Java is installed, you will see a version number like "java version 17.0.1" or similar. If you see "command not found" or "is not recognized", Java is not on your system and you need to install it before the JAR file will run.
Install Java if you do not have it
Java comes in two main versions: Oracle JDK (Java Development Kit) and OpenJDK. For running JAR files, either one works. OpenJDK is free and open-source; Oracle JDK is also free for most uses but comes from the company that created Java.
To install OpenJDK on Windows, go to adoptium.net, read the latest LTS (Long Term Support) version, and run the installer. On Mac, you can use Homebrew (a package manager) by opening Terminal and typing brew install openjdk, or read the installer from the same site. On Linux, use your package manager: sudo apt install openjdk-17-jre on Ubuntu or Debian.
After installation, restart your terminal or Command Prompt and run java -version again to confirm it worked.
Run a JAR file by double-clicking it
If Java is installed, the easiest method is to double-click the JAR file. On Windows, look for the file in File Explorer, find the JAR file (it usually has a coffee cup icon), and double-click it. On Mac, do the same in Finder. The program should launch in a new window.
If nothing happens when you double-click, the JAR file may not have been set up to run this way, or Java may not be properly linked to JAR files on your system. In that case, use the terminal method instead.
Run a JAR file from the terminal or Command Prompt
Open Command Prompt (Windows) or Terminal (Mac or Linux). Navigate to the folder where your JAR file is stored. If the file is on your Desktop, type cd Desktop and press Enter. Then type:
java -jar filename.jar
Replace "filename" with the actual name of your JAR file. If the name has spaces, put it in quotes: java -jar "my program.jar". Press Enter and the program should start.
If you get an error like "file not found", make sure you are in the correct folder. Type ls (Mac or Linux) or dir (Windows) to see all files in the current folder and confirm the JAR file is there.
Give a JAR file more memory if it runs slowly or crashes
Some JAR files need more memory than Java gives them by default. If a program is slow, freezes, or crashes with an "OutOfMemoryError", you can increase the memory limit in the terminal command.
Type java -Xmx2G -jar filename.jar to give the program 2 gigabytes of memory. Change the number before the "G" to whatever you want — -Xmx4G for 4 gigabytes, -Xmx512M for 512 megabytes. Do not ask for more memory than your computer has available.
Understand what happens when a JAR file is running
When you run a JAR file from the terminal, the terminal window stays open and shows messages from the program. If you close the terminal window, the program stops. This is normal for programs that run in the background (like servers or tools that process files). For programs with their own window (like games or editors), closing the terminal does not affect them — the program keeps running.
If a JAR file is supposed to run continuously (a server, for example), leave the terminal window open. If you want to stop the program, go back to the terminal and press Ctrl+C (on Windows, Mac, or Linux).
Frequently Asked Questions
Why does double-clicking a JAR file not work even though Java is installed?
On some systems, JAR files are not set to open with Java by default. Try the terminal method instead: open Command Prompt or Terminal, navigate to the folder with the JAR file, and type java -jar filename.jar. This bypasses the double-click association and runs the file directly.
Can I run a JAR file on a phone or tablet?
No. JAR files are designed for computers running Java. Phones and tablets use different systems (Android, iOS) and cannot run Java JAR files. Some programs have mobile versions, but they are separate downloads.
What does "jar" actually stand for?
JAR stands for Java Archive. It is similar to a ZIP file — it compresses multiple files into one package — but it is specifically designed for Java programs and includes metadata that tells Java how to run the program inside.
Do I need to unzip a JAR file before running it?
No. Java reads JAR files directly without unzipping them. If you unzip a JAR file, it will not run the same way. Just run it as-is with the java -jar command or by double-clicking.
What if I get a "permission denied" error on Mac or Linux?
The file may not have permission to run. Type chmod +x filename.jar to give it permission, then try running it again. On Windows, this is not usually necessary.