What are JAR files? This post from NewsPivot will explain this to you and show you how to run JAR files in Windows 10/11 in 3 ways. It also tells you an error you may encounter when running a JAR file.

An Overview of JAR Files

JAR, short for Java Archive, is a package file format typically used to aggregate many Java class files and associated metadata and resources (text, images, etc.) into one file for distribution.

A JAR file is an archive file built in ZIP format with a .jar file extension. Unlike ZIP files, JAR files are not only used for compression and distribution, but also for deploying and packaging libraries, components, and plug-ins. JAR files can also be used directly by tools like compilers and JVM.

A JAR file can be opened by many tools like WinZip, Gzip, WinRAR, 7-Zip, etc. In addition, a JAR file typically contains Java source files, property files, XML files, image files, and a manifest file. The entries in the manifest file describe how to use the JAR file.

a JAR file

How to Run JAR Files in Windows 10/11

Some JAR files are executable. How to run JAR files in Windows 10? Here are 3 ways.

Way 1. Use Java

Have your computer installed Java? You can open Command Prompt and then execute the command “java -version” to check that. If there is no Java installed, you should install it first.

Java mainly consists of two parts: Java Development Kit (JDK) and Java Runtime Environment (JRE). JDK contains tools needed for compiling Java programs, while JRE contains libraries and virtual machines needed for running Java programs.

JDK and JRE can both run JAR files. You can install either of them from the offical site.

If JRE is installed, you can double-click the JAR file to run it directly. If JDK is installed, you can right-click the JAR file, click Open with > Choose another app, and then choose Java Platform SE binary to run the JAR file. Java Platform SE binary is a main component of JDK.

Way 2. Use Command Prompt

Command Prompt is a powerful tool. It can also run JAR files. How to run JAR files in CMD? Here is the guide:

  1. Press the Windows Search icon and type “cmd” in the text box. 
  2. Right-click Command Prompt from the result list and choose Run as administrator.
  3. Type the command “jar -jar jarfilename.jar” to run a JAR file. The jarfilename should be the full path of the file and should be replaced accordingly.
Tips:
You can also use the command “java -cp jarfilename.jar com.example.MainClass” to run a JAR file without a manifest.

Way 3. Use a Third-Party JAR Executor

There are various third-party JAR executors on the market. You can also search a reliable one and use it to run JAR files.

Not All JAR Files Are Executable

Not every JAR file is runnable. An executable JAR file should contain at least one class that has a runnable main method. Furthermore, the class with the main method must be listed as the main class in the JAR’s manifest file.

If you try to execute a JAR file that is not meant to be run, you will get an error message that says: “Java JAR error: Could not find or load main class…

Bottom Line

How to run JAR files in CMD? How to run JAR files in Windows 10/11? This post shows you the ways. If you have other ideas, contact me and I will add them to my post in the next update.

  • linkedin
  • reddit