JAR files are common formats used to run Java applications or games and are popular for their easy distribution of resources. But, while accessing .jar files, many users encounter problems like not being able to open it, or opening it through other extraction software unwantedly. In this article, we’re going to show you some easy steps on how to open JAR files with Java in Windows 10.
How to Open JAR Files with Java in Windows 10?
To learn how to open JAR files with Java, we need to understand the Java file system basics. JAR files (.jar file extension) are also known as Java Archive files. These are an archive of compressed Java files that work on the same principle of a .zip file as a compression technique. JAR files can contain executable Java programs in addition to basic info like images, manifest file (information on other data files, also known as metadata), etc. JAR files are commonly used to distribute Java files easily as a package.
To be able to run JAR files properly, JDK (Java Development Kit) and JRE (Java Runtime Environment) are the most commonly used tools that come with all the resources to run a Java application. These are executed via JVM (Java Virtual Machine) which comes with the tools themselves.
A “Java executable” program or class is a specified execution technique which the following JAR file will follow before launching. This can be a Java-powered game or specific commands. However, for new users in the Java world, JRE gives easier execution settings and is preferable than JDK, which comes with more functionalities but an advanced user to utilize.
Generally, most of the Java application comes with their environment packaged where you can run them without using any extra application. However, many times the JAR files simply won’t open because it isn’t an executable file. To open these files, you can use the following methods:
- Using the JDK or JRE
- Decompression or archiving software
Using the JDK or JRE
If you have Java executable applications within the JAR files, you may want to use the JDK or JRE software to run them properly in the intended way. Download and install the Java Development Kit from here, which contains all necessary protocols, compilers, and debuggers to run JAR files properly. You can also download and install JRE (Java Runtime Environment) from here, which can do the same. Both of these come with pre-installed JVM (Java Virtual Machine) settings.
Set Default App for JAR Files
After installing, you should set this program as default for all JAR files. To do this, right-click on the JAR file, select Open with… and select Choose another app. A list of the compatible app comes. Here, select the Java Runtime Environment and check the box beside Always use this app to open .jar files.
Now you will notice that all the JAR files come with changed icons of JRE. Every time you run any JAR file, it will open through the Java Runtime Environment, where you can launch executable applications too. This is also useful if your default program has been set to another decompression software like the WinRAR, and you want to change it to JRE.
Still Not Opening JAR Files?
If the problem remains, you may see that JAR files aren’t opening right away even if the defaults have been set, they might be blocked by the defender. If you’re certain the files are safe, you can turn off Windows defender and try again. If the problem still remains, there’s an easy solution for that too. You might need to create a batch file to run the JAR.
- Go to the location of your JAR file.
- Right-click on an empty space and select New > Text document.
- Rename the text document anything, but set the extension from .txt to .bat so that the file changes to a Windows Batch file.
- Right-click on the new .bat file, and select Edit.
- Here, type this: (copy and paste the JAR file name in the place of example)
java –jar example.jar
For example, if the JAR file name is “Launch”, edit the .bat file as java –jar Launch.jar. Make sure the file name is correct.
- Now save the .bat file. From now, every time you open the .bat file, it will launch the JAR file.
- To extract, you can create another .bat file named jar –xf example.jar where you can paste the file name in the place of “example” and it will extract your JAR file.
If you can’t change or view your file extensions, you have to manually enable it. To do this, go to This PC. On the top-left corner, you have your View tab. Click on it and it will expand.
Now, go to Options > Change folder and search options. A dialog box appears. Here, in the View tab, find and uncheck the Hide extensions for known file types option. Click OK and now, you can see and change your file extensions as you need.
Decompression or Archiving Software
If your JAR files don’t contain executable programs, you can safely view or extract the JAR file to a specified location by using any decompressing software like the WinRAR or 7-Zip. These are very lightweight software effective for extracting compressed files.
In this process, you don’t need to download or install either JDK or JRE programs. The reason you can do this is that the JAR files are built on the same principle as other compression files like ZIP or RAR files, and conventional extraction software can handle these.
At first, you need a software like WinRAR installed on your system. To see what’s inside your JAR file, right-click on it, and select Open with… and select WinRAR. The JAR file contents will be shown through a window. To extract these files on a specified location, right-click on the JAR file and select Extract files… and select your destination location to extract the files. Now you can view and edit these files on the location.
In this article, we’ve briefly discussed how to open JAR files with Java for Windows 10. Opening JAR files with Java is the preferred method than using other decompressing software as you get all the functions needed to run executables. It is also helpful in troubleshooting Java-powered apps and games that come with it.