How To Execute A JAR File In Windows | Java Launch Steps

Run an executable JAR on Windows with Java installed, then launch it from Command Prompt using java -jar filename.jar.

A downloaded .jar file can look dead until Windows has the Java launcher available. Use Command Prompt for how to execute a JAR file in Windows before trying double-click fixes, because the command window shows the error message instead of hiding it.

The working command is short: java -jar yourfile.jar. Double-clicking can work too, but only when the JAR contains a start class and Windows points .jar files to Java instead of a zip tool.

What Makes A JAR File Executable?

A JAR file runs as an app only when it contains compiled Java classes and a manifest entry that names the start class. A JAR that only stores a library, plugin, or resources will open as an archive but will not launch by itself.

The part to check is the manifest line named Main-Class. If that line is missing, Windows has nothing to start, and Java returns no main manifest attribute.

  • An app JAR usually opens a window, starts a server, or runs a command-line task.
  • A library JAR is meant to be loaded by another app and usually needs -cp plus a class name.
  • A mod or plugin JAR usually belongs inside the host app’s folder, not in Command Prompt.

Executing A JAR File On Windows: Commands That Show Errors

Command Prompt is the better first launch method because it leaves the error on screen. A double-click can flash and close before you can read what broke.

  1. Install a current Java JDK or Java runtime if java -version does not work.
  2. Put the JAR in an easy folder, such as C:\Users\YourName\Downloads.
  3. Open File Explorer, go to the folder, click the address bar, type cmd, and press Enter.
  4. Run java -version. A version line means Windows can find Java.
  5. Run java -jar "yourfile.jar", replacing the file name exactly.

The program window, server text, or command output should appear in the same window. If the prompt returns with an error, the wording tells you which fix to use.

Launch Method Command Or Action Use It When
Command Prompt in the folder java -jar "app.jar" The JAR sits in the folder you opened.
Full file path java -jar "C:\Tools\app.jar" The JAR is not in the current folder.
Java with arguments java -jar "server.jar" nogui The app’s instructions list words after the file name.
No console window javaw -jar "app.jar" A desktop app launches fine and you do not need logs.
Batch file start.bat containing the launch command You run the same JAR often with the same options.
Double-click Open the file from File Explorer Java file association is correct and the app has a manifest.
Library launch java -cp "lib.jar" com.example.Main The JAR has classes but no launch manifest.

Oracle’s Java 26 command manual states that -jar executes a program packaged in a JAR file and that the manifest must contain Main-Class. The Java command reference for JDK 26 also notes that arguments after the JAR file name are passed into the app.

Fix Java Is Not Recognized Before Running The File

The message 'java' is not recognized as an internal or external command means Windows cannot find java.exe. Java may be missing, or the bin folder is not on PATH for the Command Prompt window you opened.

Close Command Prompt and open a new one after installing Java. If the message stays, run Java by full path once:

"C:\Program Files\Java\jdk-26\bin\java.exe" -jar "C:\Users\YourName\Downloads\app.jar"

Change jdk-26, the user folder, and the JAR name to match your PC. If that full-path command works, Java is installed; only the PATH entry needs repair.

Double-Click Problems

Double-clicking a JAR depends on Windows file association, so it is less dependable than the command line. A zip app, old Java install, or broken association can grab the file before Java gets it.

Use the command line first. After the JAR runs there, set double-click behavior only for convenience: right-click the JAR, choose Open with, pick Java(TM) Platform SE binary or OpenJDK Platform binary, and set it as the default app for .jar files. The JAR icon should change, and double-clicking should launch the same app you tested in Command Prompt.

Error Or Symptom Likely Cause Fix To Try
'java' is not recognized Java is missing from PATH. Install Java, reopen Command Prompt, or use the full java.exe path.
Unable to access jarfile The file name or folder path is wrong. Use quotes around the full path and check the .jar spelling.
no main manifest attribute The JAR has no Main-Class entry. Ask for the runnable build, or launch the main class with -cp.
UnsupportedClassVersionError The JAR was built for a newer Java version. Install a newer JDK, then rerun java -version.
A JNI error has occurred Java version mismatch or missing dependency. Match the Java version requested by the app’s download page.
The window opens and closes The app ended or crashed before you could read it. Launch from Command Prompt so the message stays visible.
The file opens in 7-Zip or WinRAR .jar files are assigned to an archive app. Change Open with to the Java binary after command-line testing.

Which Launch Method Should You Use?

Most Windows users should test a JAR with java -jar first, then add double-click or a batch file later. The first run is about getting visible feedback, not making the file pretty.

  1. Run java -version to prove Java is available.
  2. Open Command Prompt inside the JAR folder.
  3. Run java -jar "filename.jar" with quotes around the file name.
  4. If the JAR needs memory or app options, put those before or after the file name exactly as the app’s notes say.
  5. After the command works, create a .bat file or set Open with for easier launches.

A working run shows either the Java app window or steady text output in Command Prompt. A failed run shows an error you can match against the table above.

References & Sources

  • Oracle.“The java Command.”Defines the -jar option, manifest requirement, argument handling, and javaw behavior.
  • Oracle Java Downloads.“Java Downloads.”Official download page for Oracle JDK releases on Windows.
  • Eclipse Adoptium.“Eclipse Temurin.”Official source for Temurin OpenJDK builds, a common Java runtime choice for Windows.