How to run jar file windows

An interesting side effect of this causes a problem when starting runnable jar files in the command prompt.

If you try (in a command prompt):

jarfile.jar parameter

No joy, because this is being translated to the following (which doesn’t work):

javaw.exe -jar jarfile.jar parameter

However, the following command does work:

java.exe -jar jarfile.jar parameter

If you change the association in file manager as described above to:

"C:\Program Files\Java\j2re1.4.2_04\bin\java.exe" -jar "%1" %*

Then you can type:

jarfile.jar parameter

in the command prompt and it will now work!

EDIT:(However you then get a black console window when you run a form based (non console) Java app, so this is not an ideal solution)

If you run these jar files by double clicking them in windows, no parameters will be passed so your Java code needs to handle the stack overflow exception and include a «press a key» function at the end or the window will just disappear.

In order to pass a parameter in windows you have to create a shortcut to the jar file, which includes the parameter in the target line (right click on the shortcut and select properties) you can not add parameters to the jar file icon itself in this way.

There isn’t a single, consistent solution here, but you would have the same problem with any other console application.

There is a windows freeware application called «bat to exe» which you can use to create an exe file from a .bat file with the apropriate command line in it. you can also embed the jar file in the exe with this application, and make it clean it up when it has finished running, so this may be a more elegant solution.

An interesting side effect of this causes a problem when starting runnable jar files in the command prompt.

If you try (in a command prompt):

jarfile.jar parameter

No joy, because this is being translated to the following (which doesn’t work):

javaw.exe -jar jarfile.jar parameter

However, the following command does work:

java.exe -jar jarfile.jar parameter

If you change the association in file manager as described above to:

"C:\Program Files\Java\j2re1.4.2_04\bin\java.exe" -jar "%1" %*

Then you can type:

jarfile.jar parameter

in the command prompt and it will now work!

EDIT:(However you then get a black console window when you run a form based (non console) Java app, so this is not an ideal solution)

If you run these jar files by double clicking them in windows, no parameters will be passed so your Java code needs to handle the stack overflow exception and include a «press a key» function at the end or the window will just disappear.

In order to pass a parameter in windows you have to create a shortcut to the jar file, which includes the parameter in the target line (right click on the shortcut and select properties) you can not add parameters to the jar file icon itself in this way.

There isn’t a single, consistent solution here, but you would have the same problem with any other console application.

There is a windows freeware application called «bat to exe» which you can use to create an exe file from a .bat file with the apropriate command line in it. you can also embed the jar file in the exe with this application, and make it clean it up when it has finished running, so this may be a more elegant solution.

Steps to run a JAR file on Windows, Mac or Linux

To run a JAR file on Windows, Mac or Ubuntu machines, follow these steps:

  1. Verify that Java is installed on your computer
  2. Confirm the computer’s PATH variable includes Java’s \bin directory
  3. Double-click the JAR file if auto-run has been configured
  4. Run the JAR file on the command line or terminal window if a double-clicking fails

If you do not have Java installed, and the PATH variable is not set correctly, attempts to run a JAR file on Windows or Ubuntu will result in a ‘Java not recognized‘ error.

Run JARs in the Java JDK

To run a JAR file, you must install the Java JDK or JRE on your computer.

Why does double-clicking not run my JAR file?

Some Java installers configure Windows or Ubuntu to run Java JAR files when they are double clicked, but not every installer supports this configuration.

Furthermore, it is possible that you didn’t select the JAR double-click functionality during the Java install.

Is every JAR file executable?

Keep in mind that not every JAR file is runnable. Some JAR files are just support files intended to be used by other Java apps.

For a JAR file to run, the JAR itself must 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 not, the class must be explicitly stated on the command line when the JAR is run.

How do you run a JAR at the command line?

As long as you have Java installed, and the PATH variable points to the \bin directory of the JDK, you issue the following command to run a JAR file at the command line:

java -jar jarfilename.jar

This Java JAR run command assumes the JAR in question is located in the current folder. If the JAR file to run is located in a different folder, you’ll need to provide a full path to the file.

Commands to create, extract and run JAR files

Function Java JAR command
Run a JAR file  jar -jar jarfilename.jar
Create a JAR file  jar cf jarfiletocreate.jar file-list
Open a JAR file  jar xf jar-file-to-open.jar
Run a JAR without a manifest  java -cp jarfilename.jar com.example.MainClass

What is inside a JAR file?

JAR files are simply ZIP files that contain all of the resources required to run a Java application.

A JAR file typically contains:

  • Java source files
  • Property files
  • XML files
  • Image files
  • A manifest file

What does JAR stand for?

The term JAR is an acronym built from the words: Java Application aRchive.

The term ‘archive’ is really key to understanding what a JAR file is. The JAR file encompasses every file required to support an application, zipped up and compressed into a single, archive file.

The Java JAR file uses a standard compression algorithm used by all of the most popular tools. A Java JAR file is really just a ZIP file with a .jar extension.

How do I extract the contents of a JAR file?

If you look inside at its contents, you can open a JAR file and extract its contents with any standard ZIP or decompression utility.

Popular JAR file opener tools include:

  • WinZip
  • Windows Extractor
  • Gzip
  • WinRAR
  • 7-Zip

Run and open JAR file

You can open Java JAR files with any Zip utility such as 7-Zip or WinRAR.

You can also open a JAR file in Windows PowerShell or an Ubuntu Terminal window with the following command if you have the JDK installed:

jar xf name-of-jar-file.jar [files-to-open]

Why do I get a ‘Could not load main class’ error when I run my JAR?

Not all JAR files are meant to run. Some are just standard libraries with no execution capabilities at all.

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 ...

Could not load main class fix

If you get this error when you run a JAR that should be executable, the problem could be one of these issues:

  • The main-class to run was not listed in the runnable JAR file’s manifest file;
  • The JAR’s manifest file is missing; or
  • The JAR file distributor wants you to specify the main-class on the command line.

If you know the Java class that should act as the entry point of a runnable JAR, you can explicitly specify that file at the command line as follows:

java -cp jarfilename.jar com.example.EntryPointClass

Notice the flag to run the JAR file has changed from -jar to -cp.

When the main-class is not specified in the manifest file, you must use the classpath flag (-cp), not the -jar flag.

Running executable Java JAR files

JAR files are an excellent way to distribute and deploy cross-platform applications written in Java.

To run JAR files, first make sure you have Java installed, your environment is properly configured, and the JAR file’s manifest file lists the application’s entry-point. With all of these puzzle pieces in place, your Java JAR file will run without issues.

by Matthew Adams

Matthew is a freelancer who has produced a variety of articles on various topics related to technology. His main focus is the Windows OS and all the things… read more


Updated on

  • To run a JAR file on your Windows 10 device, you certainly need to have Jave installed.
  • You’ll find below a path to the latest Java version in case you need it.
  • Then, you can find JAR file openers or executors, and we recommend some. 
  • Using Command Prompt is also a handy solution if you don’t want to install third-party tools.

run a Jar file on Windows 10 PC

A JAR file is a Java archive package format that might include a Java program within it.

While you can extract JARs with archiving software, you can’t run a pure Java JAR app as you would with other programs in Windows.

Since that’s the case, we’ll cover how you can run a pure Java app JAR file in Windows.

What are JAR files?

A JAR file allows Java runtimes to enclose an entire application, together with its classes and resources, in a single source.

Moreover, the elements inside a JAR file can be compressed, and that translates to shorter download times but also less space allocated on your drive.

In other words, JARs are more sophisticated archives that work in a Java environment on your PC.

How can I run a JAR file?

In this article

  • What are JAR files?
  • How can I run a JAR file?
  • 1. Add Java to Windows
  • 2. Use Java (TM) Platform SE binary
  • 3. Download a JAR file opener
  • 4. Run a JAR file in cmd
  • 5. Add a third-party JAR executor to Windows
  • How to get a JAR file for your favorite app?

1. Add Java to Windows

  1. Type cmd in the Windows Search tab and click on the Command Prompt app.
  2. Next, input the following command and press Enter to run it: java -version
  3. The current version of Java is Version 8 Update 311.
  4. If you don’t have Java or the most up-to-date version, you can download it for free. After you get the file, hit the Install button.
  5. Run through the Java setup wizard and close the window after the installation process.
  6. Then, open your browser to verify that the program is working.

The crucial thing you need upfront is to have Java installed. It helps you open JAR files. Without it, Java apps aren’t going to run in Windows.

How we test, review and rate?

We have worked for the past 6 months on building a new review system on how we produce content. Using it, we have subsequently redone most of our articles to provide actual hands-on expertise on the guides we made.

For more details you can read how we test, review, and rate at WindowsReport.

2. Use Java (TM) Platform SE binary

  1. Press the Windows key + E to start File Explorer and the folder that includes the file you need to run.
  2. You should right-click the JAR file and select Open with from the context menu, then select Choose another app.
  3. Sselect to open it with Java(TM) Platform SE binary.
  4. Click the Always use this app to open JAR files check box, then press the OK button to close the menu.
  5. Now you can run the selected JAR, and all other JARfiles will also be associated with Java.

3. Download a JAR file opener

  1. Go to the File Viewer Plus website and click on the Download Now button.
  2. After you download and install the app, hit the Finish button.
  3. Now click on the Open a file button or just drag-and-drop the JAR file in its window.
  4. You will instantly see the contents of the JAR file and you will be able to click the Extract All button to get them on a location on your drive.

You can open JAR files with a lot of apps out there but we strongly recommend File Viewer Plus because it can open and display over 300 different file types.

The new updated version has a plethora of features that will save you big time on opening, viewing, or editing files.

Keep in mind that the app supports the most popular text, audio, or video file type, as well as archive, source code, or web files.

Another popular JAR file opener is JAR Runner, by KIllerApplets.com. You can check it out if you prefer.

4. Run a JAR file in cmd

1. Input cmd in the Search tab.

2. Select Run as administrator to run Command Prompt with full privileges.

search for cmd

3. Then input the following command (replacing pathtofile from the example with the actual path of the file you need to run): java -jar c:\pathtojarfile.jar

command to open jar file

4. Press Enter.

5. That will open the executable JAR file so long as it contains a manifest file to specify the application’s entry point (the developers should have already included that in the archive.)

If you develop your own Java programs, you’ll need to convert the JAR to an executable format.

Another easy option is to run a JAR file in cmd, your PC’s built-in command-line tool. All you need to do is input a command while running the app with admin rights, and the file will be opened.

The command-lie app is crucial for debugging and installing apps but if it doesn’t work, learn how you can fix Command Prompt in Windows.

5. Add a third-party JAR executor to Windows

  1. Visit the JARX website and click on the Jarx-1.2-installer.exe file to download it.
  2. Download and click on the file to start the installation, then select the Close button when it’s finished.
  3. Now you can just double-click any JAR file to start it like a normal executable file. The JAR file will be executed.

There are also executor programs for Windows like JARX that enable you to run .JAR files the same as any other program.

Read more about this topic

  • What is Microsoft Coffee and is it real or not?
  • Security Settings Blocked Self-signed Application [Fix]

How to get a JAR file for your favorite app?

There are lots of websites that offer free JAR versions of any application you can think of and we’re going to provide a simple example for Instagram.

  1. Go to a website that offers JAR file downloads like JAR Download. Proceed with caution because not all such websited offer clean content so you should double-check it with an antivirus and scan the files on arrival before using them.
  2. Click on the Java version of the app you’re looking for. In our case, the Instagram Java.
  3. Now hit the Download button and by using our guide above, you already know how to open the JAR and use the contents.

If you’re having trouble or you receive an error, learn what to do if you’re unable to access JarFile on Windows 10.

We hope that our guide helped you with all the information needed to run JAR files in Windows or even convert them if needed.

For any other issues, we also have another guide that will help you if JAR files are not opening on Windows 10.

If you have any other suggestions on how to run a JAR file, or questions about the topic, leave them in the comments section below and we’ll be sure to take a look.

newsletter icon

  • Home
  • News
  • How to Run JAR Files on Windows 10 – 4 Ways

By Tina |
Last Updated

JAR files are commonly used on Windows computers. Hence, do you know how to run .JAR files on Windows 10? This post from MiniTool shows how to run JAR files on Windows 10. In addition, you can visit MiniTool to find more Windows tips and solutions.

What Are JAR Files?

A JAR is a package file format typically used to aggregate many Java class files and associated metadata and resources, such as text, images,etc. into one file for distribution. JAR files are archive files that include a Java-specified manifest file. They are built on the ZIP format and typically have a .jar file extension.

However, do you know how to run .JAR files on Windows 10? If no, keep on your reading, and the following part will show you how to run JAR files.

How to Run JAR Files on Windows 10?

In this part, we will show you how to run .JAR files with several different ways.

Way 1. Add Java to Windows

The first way you can try to open JAR files is to add Java to Windows. Without it, Java apps will not run on Windows and the JAR files also will not be opened.

So, in order to run .JAR files, you need to add JAVA to Windows. Now, here is the tutorial.

  1. Open Command Prompt.
  2. Next, type java -version in the Command Line window and hit Enter to continue. It will show you the further details of Java version on your computer.
  3. If there is no Java on your computer, click here to download the latest one.
  4. Then run it on your computer.

download Java

After all steps are finished, you can run .JAR files through the JAVA app.

Way 2. Open JAR Files with JAVA Platform SE Binary

In order to run JAR files, you can also choose to run it through the JAVA Platform SE Binary.

Now, here is the tutorial.

  1. Right-click the JAR file and select Open with from the context menu.
  2. Then select Choose another app and then select it to open with Java Platform SE binary.
  3. Check the option Always use this app to open Jar files.
  4. Then press OK to continue.

After all steps are finished, you can open JAR files on Windows 10 through the JAVA Platform SE binary.

Way 3. Open JAR Files with Command Prompt

Besides the above method, you can also run .JAR files through the Command Prompt.

Now, here is the tutorial.

  1. Open Command Prompt as administrator.
  2. Type the command – java –jar c:\path\to\jar\file.jar in the Command Line window and hit Enter to continue. Please replace the c:\path\to\jar\file.jar with the actual path and file title of the JAR you need to run in Windows.

Then, it will open the executable JAR file so long as it contains manifest file to specify the applications entry point.

Way 4. Add a Third-Party JAR Executor

As for how to run JAR files, you can use the third-party JAR executor and there are various JAR executors on the market. So, in order to run the JAR file, you can download a third-party JAR executor. After that, you can open the JAR file successfully.

Final Words

To sum up, as for how to run.JAR files, this post has introduced 4 ways. So, if you want to run .Jar files on Windows 10, you can try these ways. If you have any better idea to run .JAR files, you can share it in the comment zone.

About The Author

Position: Columnist

Tina is a technology enthusiast and joined MiniTool in 2018. As an editor of MiniTool, she is keeping on sharing computer tips and providing reliable solutions, especially specializing in Windows and files backup and restore. Besides, she is expanding her knowledge and skills in data recovery, disk space optimizations, etc. On her spare time, Tina likes to watch movies, go shopping or chat with friends and enjoy her life.

  • How to open ftp on windows
  • How to install yarn on windows
  • How to run bash script on windows
  • How to recovery windows 10
  • How to open command line windows