A file with .jar extension is basically a Java Archive file that is used during run-time of Java programs related to any application. Some applications contain files that can perform the execution of .jar files. But some files need to be executed manually.
If you are dealing with such a circumstance then you have to learn how to run a jar file. We have mentioned all the practically possible methods to execute a jar file. Go through this guide to learn more.
Tips on How to Run a JAR File
As we have mentioned above, Java is a must to open a jar file. If you don’t have Java installed on your device then you can go through the methods mentioned below. We have kept the methods as minimal as possible for easy understanding.
Tip 1: Add Java
We have discussed the procedure to install Java on Windows and macOS here.
You can’t run jar files on your Windows system without installing Java. Follow the guidelines below to get Java.
- Download the latest version of Java from the official website.
- Once the download completes, double-click on the package of the jar file. If it opens, then everything is ok. Otherwise, follow the steps further.
- You can notice a pop-up window asking for your permission. Choose the Java (™) option. Next, click the OK button.
- If it still doesn’t open, make sure that the file is executable.
- Update the version of Windows that you are using.
Now, try opening the jar file on your Windows device.
Go through the instructions cited below to install Java on your Mac device.
- Download the latest version of Java on your MacBook. When you are going to install a non-Apple file on MacBook, you have to do the following. Navigate the path: Apple Menu> System Preferences> Security and Privacy. You have to unlock the menu. Choose the Open Anyway option next to the file’s name. Opt for the Open option when the prompt appears.
- Double-click the jar file to open. It should open now. If it doesn’t work, then follow the instructions further.
- A pop-up window should show up on the screen. Select the Java (™) option. Proceed with the OK button.
- Make sure whether the jar file is executable or not.
- Update Java to the newest version.
Tip 2: Open with Java(™) Platform SE Binary
If the first method didn’t help you, you can try this hack. Use these simple steps to run a jar file.
- Make sure that you have the updated version of Java.
- Next, you have to right-click on the jar file. Choose the Open With option from the drop-down menu.
- Opt for the Choose Another App option from the list.
- You have to locate and choose Java(™) Platform SE Binary option.
- Check the box next to the Always Use This App To Open Jar Files option.
- Tap the OK button.
Try opening the jar file.
Tip 3: Use Command Prompt
As an alternative, you can use the Command Prompt to run the jar file.
- Press and hold Win+X keys from the keyboard.
- Choose Command Prompt (Admin) option from the contextual menu.
- Enter the following command: java -jar c:jarfilepath.jar. Mention the path of the jar file in the place of jarfilepath. Press Enter.
- There is another quick way through the Command Prompt. Just enter ‘cd/’ followed by the path of the directory of the jar file. Finally, hit Enter.
Hope, you find the guide helpful and throws light on how to run a jar file.