Windows OS

How To Run .jar Files On Windows 10

JAR means Java ARchive. JAR files have an extension .jar, and they are based on the ZIP file format. JAR is a ZIP file for java classes. If there is a code sapling that you want to use in different projects, you can make a JAR file of those particular classes that you want to use at multiple places or projects.

This is very convenient because, in this way, you won’t have to write the same code again and again; rather, you can just pick up the JAR file and put it to use.

Although JAR files are specifically good and efficient when it comes to convenience, users often hear a complaint that they cannot open a jar file like other usual files, i.e., by either double-clicking or right-clicking to select ‘open’.

Precisely, “To run a .jar file, search command prompt and right-click on it. Select “run as administrator”. Then type the following command: –

ftype jarfile=”(File path)\javaw.exe”-jar “%1” %*

Press enter; you should now be able to run the jar file on your Windows 10.”

This article discusses a few different methods that you can try to make JAR files open and run on your Windows 10.

Method 1: Opening jar File Using Notepad

Open notepad and type in it the following text: –

java -jar (file name).jar

In place of (filename), write the name of your respective JAR file.

Click on ‘file’ then ‘save as’.Save the file with the extension ‘.bat’. Make sure you save it in the same folder where the JAR file resides. When you run this file, the jar file will open up along.

Using Java
Right-click on the jar file. Click on the ‘Properties’ option. Click on ‘change’ in the box that appears. Select “More apps”. Scroll down to the bottom and click on “look for another app on this PC”.

In the window that appears, go to C, then select “Program Files (x86)”. Find and go into the ‘java’ folder. Enter the ‘jre’ folder and select ‘bin’.

In the bin, find and choose ‘javaw’. When you click on the javaw, a box will appear. In it, click on ‘apply’ and then on ‘Ok’. Once this is done, you can directly click and run the JAR file.

Method 2: Opening jar File Using Command Prompt

Go to the search box at the bottom of your home screen and search for ‘cmd’ or  ‘command prompt’.Right-click on the command prompt and select “Run as administrator”.

Give the required permissions to the command prompt, such as making changes to the system. Once the dark interface of the command prompt opens up, type the below-mentioned command: –

ftype jarfile=”(File path)\javaw.exe”-jar “%1” %*

Here, in place of (File path), copy and paste the path where your JAR file is stored.

Hit enter after you have typed this command, and then you should be able to open and run your JAR file.

Method 3: If your jar file is in WinRAR format

Another issue that a lot of users face with jar files is that their jar files are in the format of WinRAR files, and when they try to open it, it opens in WinRAR instead of the java format. To fix this problem, one has to convert the file from WinRAR to actual java format. This issue mainly arises due to 2 things: –

  • You do not have a ‘Java development kit’ or JDK installed on your Windows 10.
  • You have not set it as the default program for opening your jar files.

JDK vs. JRE
If you do not have the java development kit installed, but you have the java runtime environment or JRE on your laptop, you can fix this issue without installing the java development kit. Although installing and using JDK is advised since it is more convenient and more user-friendly.

The basic difference between the JDK and the JRE is that JDK contains everything that a JRE has, but on top of all the features of JRE, it also has other useful tools such as compilers and debuggers. These tools make running java files much more convenient.

Installing JDK
To install JDK, go to https://www.oracle.com/in/index.html and download the latest JDK that corresponds to your system specifications. After the download is complete, you can install it with the default configurations.

Now, follow the steps mentioned below to make your WinRAR file look like an actual java file and make it open with java by default.

Method 4

Open your file explorer and click on the ‘view’ tab.

Go to where it says ‘options’ and click on the drop-down arrow. Click on “Change folder and search options”. In the dialogue box that pops up, click on the ‘view’ tab. Scroll down in the list to find “Hide extensions for known file types”. Uncheck the corresponding checkbox and click on ‘apply’, and then hit ‘Ok’

After being done with the above-mentioned steps, we now have to set JDK as the default program with which our files open when we double click or right-click to open them. To do this, simply right-click on the jar file and select ‘open with’. Then click on ‘choose another app’. Out of the app list that appears, select “Java(TM) Platform SE binary”. At the bottom of the dialogue box, you will find a checkbox that says, “Always use this app to open .jar files”, check that box.

This should help your jar file look like an actual java file and make it run on java by default every time you open it.

After converting your WinRAR file to a java file and setting up the default program to run it, if nothing happens when you double click on it, follow any of the first three methods mentioned in this article.

After all this knowledge, you should not face any issues with JAR files ever.

About the author

Kavita Sharma