How to Run JAR Files on Windows 10
A jar file is short for a Java ARchive file and holds java programs (Java class files, metadata, and resources) within it. Being a package file format (similar to .zip file format ), a jar file may also be used to pack together several other files to improve portability and decrease the amount of space that these files take up. This makes jar files extremely versatile and can be used to store a game, an application, a browser extension, etc.
Not all jar files are created equal. Some are meant to be run/executed like .exe files and others extracted/unpacked like .zip files . While unpacking jar files is quite easy and can be done similarly to how one would extract the contents of a zip file, the same isn’t the case for executing a jar file.
A .exe file when double-clicked launches a program/application with the help of the Windows OS. Similarly, a .jar file can be executed by launching it using the Java Framework. However, many users face errors when trying to execute jar files and today, in this article, we will shed some light on the matter and reveal how to run or execute jar files on Windows 10.
Why won’t jar files run?
A Jar file includes a manifest that essentially tells the file how to behave while holding information about the other files packed within the jar file. Also, a jar file contains class files that hold the java code for the executable program. Both of these files along with other media files make it possible to run jar files as a single request by Java Runtime Environment.
Users come across one of these two errors when trying to run a jar file.
- The Java Run-Time Environment is not properly set to run .jar files
- Windows Registry is not calling JRE (Java Runtime Environment) properly
The first error arises when the user is running an outdated version of java on his or her personal computer and the second one is caused when the jar files are not properly associated with the Java binary.
Also, sometimes when a user double-clicks on a jar file, a command prompt window launches for a split-second and then closes back down leaving the user in dismay. Fortunately, resolving these two errors and running a jar file is quite easy.
How to Run JAR Files on Windows 10
As mentioned earlier, you require the Java Runtime Environment to run the application/code contained inside a jar file. To check what version of Java your personal computer is running and how to update to the latest version, follow the below-mentioned steps:
1. Launch Command Prompt as Administrator by any of the methods mentioned below.
a. Press Windows key + X or right-click on the start button to open the power user menu. From the ensuing menu, click on Command Prompt (Admin).
b. Press Windows key + R to launch Run command, type cmd and press ctrl + shift + enter.
c. Click on the start button (or press the Windows key + S), type command prompt and select Run as Administrator from the right panel.
2. Once the command prompt window is open, type java -version and press enter.
The command prompt will now provide you with the exact version of Java you have installed on your system.
Alternatively, search for the configure java application on your PC and click on About in the general tab to retrieve java version.
3. The latest version of Java is Version 8 Update 251 (as of 14th April 2020). If you aren’t using the latest version or don’t have Java at all, head over to the official download page Java Downloads for All Operating Systems and click on the “Agree and Start Free Download” button.
4. Locate the downloaded file (This PC > Downloads) and double-click on the .exe file to open the setup wizard. Now, follow the on-screen prompts to install the latest version of Java.
5. Reiterate through steps 1 and 2 to check if the update was successfully installed.
If you are facing any issues in updating java, try completely removing the previous version first using the official Java Removal Tool and then performing a fresh install.
Method 1: Using ‘Open With…’
In the first method, we manually open the jar file with the Java Runtime Environment. Follow the below steps to do the same.
1. Open the file explorer (Windows key + E), locate the jar file you would like to execute/open and right-click on it.
2. From the following file options/context menu, select Open with.
3. Go through the list of applications and try to locate Java(TM) Platform SE binary. It is most likely that you won’t find it in the list of applications.
4. So, click on Choose another app.
5. Again, go through the list and if do not find the application click on More Apps > Look for another app on this PC to manually find the application
6. Now, navigate to the path where java.exe is stored. For most users, it should be C:\Program Files\Java\jre1.8.0_221\bin but if you do not find it there, try going down the following path C:\Program Files (x86)\Java\jre1.8.0_221\bin
7. Finally, select java.exe and press enter.
Method 2: Run JAR files using the Command Prompt
One can also run jar files using the Windows 10 command prompt window. The process involves executing a single command line and is easy to perform.
1. Launch Command Prompt as Administrator using any of the methods mentioned earlier.
2. Once the command prompt window has launched, run the command ‘cd \’ to return to the top of the directory.
3. Now, type the following command java -jar sample.jar and hit the enter key.
Do not forget to change ‘sample.jar’ in the command line with the name of the .jar file.
Alternatively, you can skip the second step and replace sample.jar with the complete path of the jar file.
Also Read: Fix Java was started but returned exit code 1
Method 3: Using Third-Party Applications
Just like for everything else, there exist multiple third-party applications that let you run or execute jar files on Windows 10. One of the more popular jar executor programs out there on the internet is Jarx.
Head over to the official site Jarx – The JAR executer and download the software file by clicking on ‘Jarx-1.2-installer.exe’. Locate the downloaded file and install Jarx. The application doesn’t have a GUI except for an about window. Now, simply double-click on the jar file or right-click and select open to run jar files on your personal computer.
Another third-party application that will aid you in running jar files is Jarfix . Follow the same procedure as discussed for Jarx to run jar files.
Note: Jarfix will only be able to run jar files when launched as an administrator.
Method 4: Extract the Jar Files
As mentioned earlier, not all jar files are designed/meant to be an executable file. Some just work as a package and hold other types of files in them. We can check if a jar file is executable or not by simply unpackaging/extracting it.
If you have ever worked with zip files and rar files, chances are, you already know how to extract a file. One can choose to use the builtin extraction tool in windows or take assistance from one of the many files extracting applications available on the internet. Some of the most used and trusted applications are 7-zip and WinRAR .
To extract a file using Windows’ in-built extracting tool, simply right-click on the jar file and select one of the ‘Extract…’ options.
To extract a file using a third-party application, first, head over to the application’s website and download the installation file. Once you are done installing the application, open the jar file in the application to see the content it holds.
Fix Unable to Open JAR Files on Windows 10
If you were not able to run the jar files using any of the above methods, then try going through the following solution.
Solution 1: Updating Registry Editor
1. Launch File Explorer (Windows Key + E) and navigate to the bin folder inside the java installation folder.
The folder destination varies depending on the drive partition you have it installed on. However, for most users, the folder can be found in C drive and inside Program Files or Program Files (x86).
2. Inside the bin folder, find java.exe, right-click on it and select Properties.
3. Switch over to the Compatibility tab and tick the box next to Run this program as an Administrator. Click on Apply followed by Ok to exit.
4. Launch Command Prompt as administrator by any of the methods mentioned earlier.
5. Depending on your requirements type one of the following commands in the command prompt window and press enter.
Do not forget to replace C:\Program Files(x86)\ with your actual Java installation folder address.
To simply launch the jar file, type the following commands and hit Enter:
6. If you would like to debug the jar file and thus need the command prompt window to stay open after launching the file, type the following command
Now go ahead and try opening the jar file.
If you are still not able to execute the jar file, we will need to change a few things in the Windows Registry Editor. We advise you to be extremely cautious in following the below guide as the Registry Editor is a powerful tool and shouldn’t be messed with.
1. Launch the Windows Registry Editor by clicking on the start button, searching for registry editor and pressing enter or by typing regedit in the run command (Windows Key + R).
2. From the left-hand panel, click on the arrow or double click on HKEY_CLASSES_ROOT to expand the same.
3. From the drop-down list, find the folder jarfile (Some users may find the folders jar_auto_file and jarfileterm instead of jarfile. Follow the same procedure as mentioned below)
4. First open jarfile by double-clicking on it.
5. Navigate to jarfile > shell > open > command
5. On the right-hand panel, you should see a key labelled Default. Right-click and select Modify or simply double-click on it to modify the key.
6. In the following pop up box, under the Value Data label, paste the fftype command we entered earlier in the command prompt window.
7. Cross-check to make sure it is correct and press OK.
Note: Remember to follow the complete the procedure for both folders, jar_auto_file & jarfileterm, if you have them)
8. Finally, close the registry editor and try launching the jar file.
Solution 2: Change Java Security Settings
Another very common issue with Java is the security risk. A warning message claiming risk often pops up when trying to run a jar file. To resolve this, we simply need to change the security settings.
1. Click on the start button or press Windows Key + S, search for Configure Java and press enter to open.
2. Switch over to the Security tab by clicking on the same.
3. Make sure the box next to ‘Enable Java content for browser and Web Start applications’ is ticked.
4. Set the security level for applications not on the Exception Site list to High and click on Apply.
5. Click on OK to exit.
- How to Disable Adobe AcroTray.exe at Startup
- How to Rename Multiple Files in Bulk on Windows 10
We hope you were able to run or execute your jar file on Windows 10 as intended. In case of any issues following the above guide or in opening a jar file, connect with us in the comments section below and we will help you out.