A JAR file is a Java program packaged into a single file, and you run it by typing a command in your terminal or command prompt

A JAR file (Java Archive) is a compressed folder containing Java code and everything that code needs to run. When someone gives you a JAR file, they are giving you a complete, ready-to-run program — but unlike an .exe file on Windows or an .app on Mac, you cannot just double-click it. You have to tell your computer to run it using a command.

The command is straightforward: java -jar filename.jar — but it only works if Java is installed on your computer. If you try to run a JAR file and nothing happens, Java is probably missing. This guide explains how to check for Java, how to run the JAR file once you have it, and what to do when things go wrong.

Key Takeaways

  • JAR files require Java to be installed on your computer; without it, the file will not run no matter what you do.
  • You run a JAR file by opening your terminal or command prompt and typing java -jar filename.jar in the folder where the file is located.
  • On Windows, you can check for Java by opening Command Prompt and typing java -version; on Mac or Linux, use Terminal the same way.
  • If double-clicking the JAR file does nothing, Java is either not installed or not set up to open JAR files by default.
  • Some JAR files need extra memory or settings to run; these are passed as flags before the filename, like java -Xmx2G -jar filename.jar.

Check whether Java is installed on your computer

Before you try to run a JAR file, confirm that Java exists on your system. On Windows, click the Start menu, type "Command Prompt", and open it. On Mac, open Applications, go to Utilities, and click Terminal. On Linux, open your terminal process.

In the window that opens, type this exactly: java -version and press Enter. 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 "java is not recognized", Java is not installed or not set up correctly on your system.

If Java is missing, you need to install it. Go to oracle.com/java/technologies/downloads or adoptium.net (both are free). read the version for your operating system, run the installer, and follow the steps. After installation, open your terminal or command prompt again and type java -version to confirm it worked.

Open the terminal or command prompt in the right folder

JAR files run from a specific location on your computer. You need to open your terminal or command prompt in the folder where the JAR file is sitting. If your JAR file is on your Desktop, you open the terminal in the Desktop folder. If it is in Downloads, you open the terminal there.

On Windows, the easiest way is to open File Explorer, navigate to the folder with your JAR file, hold Shift, right-click in an empty space, and select "Open PowerShell window here" or "Open Command Prompt window here". On Mac, open Terminal, then drag the folder containing your JAR file into the Terminal window — this automatically navigates you there. On Linux, open your terminal, type cd followed by a space, then drag the folder into the terminal window, and press Enter.

Once you are in the right folder, type ls (Mac or Linux) or dir (Windows) and press Enter. You should see your JAR file listed. If you do not see it, you are in the wrong folder — navigate to the correct one and try again.

Run the JAR file with the correct command

Now that Java is installed and you are in the right folder, type this command: java -jar filename.jar — but replace "filename" with the actual name of your JAR file. For example, if your file is called "minecraft-launcher.jar", you would type java -jar minecraft-launcher.jar. Press Enter.

The program should start. Some JAR files open a window when ready. Others print text to the terminal and keep running in the background. Some run silently with no visible output at all — if the command does not produce an error, it is probably working.

If you see an error message, read it carefully. Common errors include "file not found" (you typed the filename wrong or you are in the wrong folder), "no main manifest attribute" (the JAR file is not set up to run as a program), or "OutOfMemoryError" (the program needs more memory than your computer is giving it).

Give the JAR file more memory if it needs it

Some JAR files — especially games, video editors, or data analysis tools — need more memory than Java gives them by default. If a JAR file crashes with an error mentioning "OutOfMemory" or "heap space", you can increase the memory limit.

The command changes slightly: java -Xmx2G -jar filename.jar tells Java to use up to 2 gigabytes of memory. You can change the number: -Xmx1G for 1 gigabyte, -Xmx4G for 4 gigabytes, and so on. Do not ask for more memory than your computer has available — if your computer has 8 gigabytes total, do not ask Java for 6 or more, because your operating system and other programs need memory too.

Type the full command with the memory flag and press Enter: java -Xmx2G -jar filename.jar. If the program runs without crashing, you have found the right amount of memory. If it still crashes, try increasing it further.

Make JAR files double-clickable on Windows (optional)

On Windows, you can set up your computer so that double-clicking a JAR file runs it automatically, without opening the command prompt. This requires changing a system setting and is optional — the command-line method always works.

Open File Explorer, find any JAR file, right-click it, and select "Open with" and then "Choose another app". Scroll down and click "Look for another app on this PC". Navigate to your Java installation folder — usually C:\Program Files\Java\jdk-[version]\bin — and select java.exe. Check the box that says "Always use this app to open .jar files" and click Open.

From now on, double-clicking a JAR file will run it. If it does not work, the Java path may be different on your system, or your Windows account may not have permission to change file associations. In that case, stick with the command-line method — it is more reliable.

Troubleshoot when a JAR file will not run

If you have followed all the steps and the JAR file still will not run, work through these checks in order. First, confirm Java is installed by typing java -version in your terminal again — sometimes Java updates require a restart. Second, confirm you are in the right folder by typing ls or dir and checking that your JAR file is listed. Third, check that you typed the filename exactly right, including capitalization and the .jar extension.

If the JAR file runs but crashes when ready, check the error message. "No main manifest attribute" means the JAR file is not designed to run as a standalone program — it might be a library meant to be used by other programs instead. "OutOfMemoryError" means you need to increase memory as described above. "Exception in thread main" followed by other text usually means the program is looking for a file or setting that is not on your computer.

If you cannot solve it, search the internet for the exact error message along with the name of the program. Most popular JAR files have documentation or forums where other people have solved the same problem.

Frequently Asked Questions

Why can't I just double-click a JAR file like I do with other programs?

JAR files are designed to work on any operating system — Windows, Mac, or Linux — because Java runs the same way on all of them. This flexibility means JAR files do not have the same automatic launch setup that Windows .exe files or Mac .app files do. You have to tell Java to run them explicitly, either through the command line or by setting up Windows to do it automatically.

What if the JAR file needs a password or configuration file?

Some JAR files expect additional files to be in the same folder — a configuration file, a password file, or a data folder. Check the documentation that came with the JAR file or the website where you downloaded it. If files are missing, the program will usually print an error message telling you what it is looking for. Place those files in the same folder as the JAR file and try running it again.

Can I run a JAR file on my phone or tablet?

Not directly. Phones and tablets do not have Java installed the way computers do. Some Android phones can run Java programs through special apps, but this is not common. If you need to run a JAR file on a mobile device, check whether the program has an Android or iOS version available instead.

Is it safe to run a JAR file I downloaded from the internet?

A JAR file is just code, so it carries the same risks as any program you read. Only run JAR files from sources you trust — official websites, well-known projects on GitHub, or recommendations from people you know. If you are unsure about a file, scan it with antivirus software before running it, or ask in a technology forum whether the source is legitimate.

What does the -jar flag actually do?

The -jar flag tells Java that the file you are giving it is a JAR archive and that it should look inside for the main program to run. Without this flag, Java would try to treat the filename as a class name instead, which would fail. Other flags like -Xmx adjust how Java runs; -jar is the one that identifies the file type.