- How to open a jar file
- To run the file (Java Runtime Environment)
- To view the file (decompression)
- How to run a JAR file on Windows 10 [QUICK GUIDE]
- How can I run a JAR file on Windows 10?
- 1. Add Java to Windows
- 2. Download a JAR file opener
- File Viewer Plus
- 3. Use Java(TM) Platform SE binary
- 4. Run a JAR file from the Windows Command Prompt
- 5. Add a third-party JAR executor to Windows
- How to open/run .jar file (double-click not working)?
- 15 Answers 15
- How to run a JAR file
- 11 Answers 11
How to open a jar file
To open a jar file in Windows, you must have the Java Runtime Environment installed. Alternatively, you can use decompression software, such as an unzip utility, to view the files in the jar archive.
To run the file (Java Runtime Environment)
To run the jar file, you need to download and install the Java Runtime Environment (if you do not have it already) from the link below.
Once downloaded, you can run any jar file by double clicking the file name. Keep in mind that this only works if the jar file to be opened is executable. If it’s not executable, you can view files within it instead.
If double-clicking the jar file does not result in the file being run, it’s likely not an executable file and cannot run in this manner. Read the next section on how to view the contents of the jar file.
If the jar file opens using an archive program, such as WinRAR or 7-Zip, and you want Java to open it instead, follow the instructions below. (The jar file must contain executable Java code for these steps to work.)
- Right-click the file and select Open With.
- In the Open With window, click the Browse button to open the File Explorer window.
- You need to find the Java executable file (java.exe file) on your computer hard drive. It is often located in the «Program Files\Java» or «Program Files (x86)\Java» folder, within a possible subfolder below the Java folder. Once you find the file, select it and click OK.
To view the file (decompression)
To view individual files in a non-executable jar file, you can obtain compression/decompression software that works with jar files. We recommend using either 7-Zip or WinRAR.
Once you have installed this software, run the software, open the jar file, and extract the files contained in it. Once the files are extracted, you can view the individual files by double clicking them. Many of those files are probably text files, but others may require additional software to view them.
If the jar file defaults to be opened with an archive program, such as WinRAR or 7-Zip, you can change the default program. To change the default program that opens jar files, right-click the jar file, select Open With, then Choose default program. In the Open With window, click the Browse button to open the File Explorer window. You need to find the executable file (.exe file) for the software program you want to set as the default program to open the jar file.
How to run a JAR file on Windows 10 [QUICK GUIDE]
- To run a JAR file on your Windows 10 device you certainly need to have Jave installed.
- You’ll find below a path to the latest Java version in case you need it.
- Then, you can find JAR file openers or executors, and we recommend some.
- Using Command Prompt is also a handy solution if you don’t want to install third-party tools.
A JAR file is a Java archive package format that might include a Java program within it. While you can extract JARs with archive software such as 7zip, you can’t run a pure Java JAR app as you would with other programs in Windows.
Since that’s the case, we’ll cover how you can run a pure Java app JAR file in Windows.
How can I run a JAR file on Windows 10?
1. Add Java to Windows
The crucial thing you need upfront is to have Java installed. Without it, Java apps aren’t going to run in Windows. This is how you can install or update Java in Windows 10:
- First, open Command Prompt(Admin) by pressing the Win key + R keyboard combination and entering cmd in the box.
- Next, input java -version in the Command Prompt and press Enter. It will then provide further details on your Java version as below.
- The current version of Java is Version 8 Update 131. If you don’t have Java or the most up-to-date version, you can add it for free.
- Run through the Java setup wizard. Then, open your browser to verify that the program is working.
2. Download a JAR file opener
You can open JAR files and hundreds of different formats with a single application. File Viewer Plus is a universal file viewer for Windows that can open and display over 300 different file types.
The new updated version has a plethora of features that will save you big time on opening, viewing, or editing files.
File Viewer Plus supports the most popular text, audio or video file type, as well as archive, source code or web files.
File Viewer Plus
3. Use Java(TM) Platform SE binary
- Open the File Explorer and the folder that includes the file you need to run.
- You should right-click the JAR file and select Open with from the context menu.
- Click Choose another app and then select to open it with Java(TM) Platform SE binary.
- Click the Always use this app to open JAR files check box.
- Press the OK button to close the menu.
- Now you can run the selected JAR, and all other JARfiles will also be associated with Java.
4. Run a JAR file from the Windows Command Prompt
- Press the Win key + X hotkey and select Command Prompt (Admin) to open it as administrator.
- Then input the following command (replacing the example with the actual path of the file you need to run) and press Enter: java -jar c:pathtojarfile.jar
- Alternatively, you can open the folder that includes the JAR in the Command Prompt first by entering cd / followed by the directory. Then, you can input java -jar file.jar without the folder path.
That will open the executable JAR file so long as it contains a manifest file to specify the application’s entry point. (The developers should have already included that in the archive.)
If you develop your own Java programs, you’ll need to convert the JAR to an executable format.
5. Add a third-party JAR executor to Windows
There are also executor programs for Windows that enable you to run JAR files the same as any other program . Jarx is one of them and you can add it to Windows by clicking Jarx-1.2-installer.exe on this page.
Click the jarx .exe to run the software, which doesn’t really have a GUI as such (except an About jarx window). Then you can double-click the JAR files to run them in Windows.
If you’re having trouble accessing the JAR file or you get some kind of an error, take a look at this nifty guide to finding some great fixes.
With all this, you can now run JAR files in Windows. If you need to fix a JAR file that isn’t opening, check out this Windows Report guide.
If you have any other suggestions or questions, leave them in the comments section below and we’ll be sure to take a look.
How to open/run .jar file (double-click not working)?
I can’t open or run my .jar file.
I just installed java, but I tried to open the .jar with other programs first, so the double-click defaults to something else and I can’t change it back.
Above command returns:
‘java’ is not recognized as an internal or external command, operable program or batch file.
Is there a way I can still open/run this?
e: OS is Windows 8.
Also, I downloaded the .jar file; didn’t create it myself (if that’s relevant) Not sure if it contains an executable (but I think it does).
15 Answers 15
you can use the command prompt:
Hope it works for you.
There are two different types of Java to download: The JDK, which is used to write Java programs, and the RE (runtime environment), which is used to actually run Java programs. Are you sure that you installed the RE instead of the SDK?
Use cmd prompt and type
To run your jar file.
for more information refer to this link it describes how to properly open the jar file. https://superuser.com/questions/745112/how-do-i-run-a-jar-file-without-installing-java
You may have several JDKs installed in your PC. Some older JDK installers also copy some java files such as java.exe , javaw.exe into C:\Windows\System32 folder.
I had a similar issue, and searched the internet for a solution and none of the suggestions didn’t open by double clicking the .jar file.
In my case the reason is I have multiple JDK & JRE versions installed on my computer. Since I am a software developer working with several different versions for different clients I need to use multiple JDKs in my PC (Windows 10 Pro). So I do not want to change the system variables (i.e. JAVA_HOME , JRE_HOME or PATH ), instead I use command prompt to run java in user process whenever I wanted to use a different version.
When installing JDK it registers the .jar file association with latest version we installed in the PC. If you right click on the .jar icon and select properties, it will show that file opens with “Java(TM) Platform SE Binary”. If we look at the registry key: HKEY_CLASSES_ROOT\jarfile\shell\open\command , it will point to latest JDK version.
It is not a good idea (sometimes annoying) to change the registry key every time I want to run an app build from a different version.
So in my situation it is impossible to just double click the .jar file to execute it. But instead I found a work around solution myself.
Scenario:
Multiple JDKs (1.7, 1.8, 9.0, 10.0, 11.0, and 12.0)are installed in the PC, so the latest installed was 12.0.
Problem
Want to double click an executable .jar developed using JDK 1.8 and didn’t work
This is my work around solution:
Create a shortcut for the .jar file that you want to open.
Right click the shortcut icon and select properties -> Shortcut tab
Change the text in the target (for example «D:\Dev\JavaApp1.8.jar» ) To
How to run a JAR file
I created a JAR file like this:
I ran this JAR file by double clicking on it (it didn’t work). So I ran it from the DOS prompt like this:
It raised «Failed to load main class» exceptions. So I extracted this JAR file:
and I ran the class file:
It worked well. I do not know why the JAR file did not work. Please tell me the steps to run the JAR file
11 Answers 11
You need to specify a Main-Class in the jar file manifest.
Oracle’s tutorial contains a complete demonstration, but here’s another one from scratch. You need two files:
Note that the text file must end with a new line or carriage return. The last line will not be parsed properly if it does not end with a new line or carriage return.
Before run the jar check Main-Class: classname is available or not in MANIFEST.MF file. MANIFEST.MF is present in jar.
You have to add a manifest to the jar, which tells the java runtime what the main class is. Create a file ‘Manifest.mf’ with the following content:
Change ‘your.programs.MainClass’ to your actual main class. Now put the file into the Jar-file, in a subfolder named ‘META-INF’. You can use any ZIP-utility for that.
A very simple approach to create .class, .jar file.
Executing the jar file. No need to worry too much about manifest file. Make it simple and elgant.
Java sample Hello World Program
Compiling the class file
Creating the jar file
Running the jar file
If you don`t want to create a manifest just to run the jar file, you can reference the main-class directly from the command line when you run the jar file.
This sets the which main-class to run in the jar file.
On command Line:
If you don’t want to deal with those details, you can also use the export jar assistants from Eclipse or NetBeans.
Eclipse Runnable JAR File
Create a Java Project – RunnableJAR
- If any jar files are used then add them to project build path.
- Select the class having main() while creating Runnable Jar file.
Run Jar file using java program (cmd) by supplying arguments and get the output and display in eclipse console.
Help ► Help Contents ► Java development user guide ► References ► Menus and Actions
I have this folder structure:
D:\JavaProjects\OlivePressApp\com\lynda\olivepress\Main.class D:\JavaProjects\OlivePressApp\com\lynda\olivepress\press\OlivePress.class D:\JavaProjects\OlivePressApp\com\lynda\olivepress\olives\Kalamata.class D:\JavaProjects\OlivePressApp\com\lynda\olivepress\olives\Ligurian.class D:\JavaProjects\OlivePressApp\com\lynda\olivepress\olives\Olive.class
Main.class is in package com.lynda.olivepress
There are two other packages:
1) Create a file named «Manifest.txt» with Two Lines, First with Main-Class and a Second Empty Line.
2) Create JAR with Manifest and Main-Class Entry Point
D:\JavaProjects\OlivePressApp> jar cfm OlivePressApp.jar Manifest.txt com/lynda/olivepress/Main.class com/lynda/olivepress/*
java -jar OlivePressApp.jar
Note: com/lynda/olivepress/* means including the other two packages mentioned above, before point 1)