JAR files are like EXE files, except that they need a Java framework to run. Imagine them as EXE files on Windows, which you can double-click to launch the program. When you run an EXE file, it uses Windows OS support. Similarly, when you run JAVA or JAR files, you need the help of Java Framework to open them. When we say open JAR file, we are not opening the file like an archive file, but we are executing it. In this post, I will share how to open or run a JAR file on Windows 11/10.
What is Java executable JAR file?
A JAR file is an archiving format that not only stores directories and source files and can also be run as executable files. Such Java ARchive files can contain Java class files that will run when the JAR is executed.
While Archiver tools like 7-Zip can extract content from JAR files, but doing that is pointless – we need to execute the files just as we run the EXE files.
How to run a JAR file in Windows 11/10
Since Java or JAR files can’t run on Windows on their own, you need to install the Java Framework or what is popularly called Java. That said, Java files can be dependent on a particular version of Java. So the steps you need to take to open JAR files on Windows 11/10 are:
- Download and install Java.
- Set the System path
- Run the JAVA file
- Set Java file association
- Establish a file association with Java runtime.
1] Download and install Java Framework
To run a JAR file on Windows, you need to install Java on your system. Go to Java Download Page, and install it. The default will install the latest version only. However, if your JAR file needs a different version of Java, you can download it from here.
Sometimes, an existing older version of Java can cause an issue. So, if you are facing such a problem, make sure to remove the older version first. Use the official Java Remover tool to get rid of it. Then install the latest version.
2] Set System Path for Java
Next, you need to set the JAVA_HOME path. It ensures that any JAVA file you run can find the necessary libraries for the program. You can also use the command line to echo the Java path to determine if it is correct.
3] Run a Java or JAR file
Now when you double click on the JAR file, it will automatically run like how EXE files execute. If there is a problem with version, the file should inform you.
If you have a JAR file which is not running on its own, then you can use java JDK to run it. Open Command Prompt, and type java -jar name_of_jar_file.jar. It will execute the JAR file automatically.
4] Set the Java or JAR file association
The last step is to establish a file association with Java runtime. It will make sure that every time you run, you are not asked to select a program that can execute it.
- Shift + Right-click on the file, and select Open with option.
- Select ‘Choose another app.’
- If Java(TM) Platform SE binary is not in your list, scroll, and then click on More Apps.
- And then choose Select app from the computer.
- You should see ‘Java(TM) Platform SE binary’ listed in this context menu but don’t select it.
- Locate the file which can run the JAVA or JAR file which is available in the path we suggested above.
- Make sure to check the box which says, “Always use this program.”
Once done, all future JAR files will automatically open with Java run time library. You should see the Java icon for all of these files.
How run Java JAR from command line?
You’ll need to use the java command to run a .jar file
java -jar <finename>.jar
If you don’t have java installed, you can fix that by installing the default-jre
package.
We hope these tips were easy to understand and were of help to open or run a Java file on Windows 11/10.