Jar (Java ARchive) or “executable Jar file” is executed by Java Runtime Environment (javaw.exe) program. On Windows, the Java Runtime Environment’s setup will register a default association for Jar files so that double-clicking a Jar file on the desktop will automatically run it with “
javaw.exe -jar” command-line argument.
A third-party application (especially unzip tools) may overtake the JAR file association in some cases. Note that Java ARchive (or executable Jar) files are built on the ZIP format and typically have a .jar file extension. The .Jar file may show up with a wrong icon which indicates that the file association is incorrect.
Since .Jar files need to be run with the special command-line argument as explained above, simply reassociating the .Jar files via the Open with dialog won’t help.
You may be wondering how to repair or restore the .JAR file association (i.e., set default double-click action to Java Runtime Environment program) in Windows.
[Fix] .JAR (Executable Jar File) File Association in Windows
There are several ways to fix the .JAR file association in Windows. Follow one of the methods below:
Method 1: Using the “JarFix” Utility
If you double-click on a jar file, and your Java application does not start, your .jar association has been hijacked. You can fix the problem with Jarfix.
Download Jarfix: https://johann.loefflmann.net/en/software/jarfix/index.html#Download
This little portable app automatically finds the Javaw.exe location (by finding the current Java version and Java Home path from the registry) and fixes the .JAR file association settings in the registry.
There you go! JAR files are now showing up with the Java coffee cup icon.
Note down the Java Home Path
Note: Before proceeding to the following methods, you need to locate the path to javaw.exe. You can easily locate the file by browsing the “
Program Files\Java” directory.
Alternately, you can run the following command in the Command Prompt window to locate the path to
reg query hklm\software\javasoft /v javahome /s
The above command searches and queries the
JavaHome value in the Windows registry which stores the information we need.
For illustrative purposes in this article, let’s assume the file
Javaw.exe is located here:
Method 2: Using ASSOC AND FTYPE commands
To fix the .Jar file association using command-line, open an admin Command Prompt and run the following commands one by one:
assoc .jar=jarfile ftype jarfile="C:\Program Files\Java\jre1.8.0_333\bin\javaw.exe" -jar "%1" %* reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.jar" /f
- If the path to javaw.exe is different in your case (perhaps due to a different JRE version), input the correct folder name in the 2nd command.
- Please ignore if the 3rd command returns the following error:
ERROR: The system was unable to find the specified registry key or value.
Method 3: Using the Registry Editor
- Start the Registry Editor (
- Go to the following location:
(default)and set its data as “
jarfile” (without quotes)
- Go to the following location:
(default)and set its data to:
"C:\Program Files\Java\jre1.8.0_333\bin\javaw.exe" -jar "%1" %*
- Go to the following branch and expand it:
- Check if a subkey named “
.jar” exists under the “
FileExts” branch. If so, right-click on the
.jarsubkey and choose Delete. This is an important step!
- Exit the Registry Editor.
Note: If the path to javaw.exe is different in your case (perhaps due to a different JRE version), input the correct path to javaw.exe in Step 5 above.
Method 4: Using a Registry (.REG) file
The steps listed under Method 3 can be automated using the following registry file. This can be helpful especially if you want to fix the JAR file association on multiple computers.
- Download the above jarfix.reg registry file (use right-click → “Save target as” in your browser).
Note: If the path to javaw.exe is different in your case (perhaps due to a different JRE version), input the correct folder name in the REG file. Be sure to preserve the double slashes in the REG file though.
- Double-click on the Registry file to apply the settings to the registry.
Method 5: Reinstalling Java Runtime Environment
Uninstalling and then reinstalling Java Runtime Environment should add Java Home Path in PATH environment variable and also fix the .Jar file association settings. However, if there is a per-user override for .Jar file type (i.e., the “FileExts\.jar” registry key), the JRE installer may not remove it. In that case, you need to follow one of the four methods above.
Thats it! You should now be able to run any .Jar file by double-clicking on it.
One small request: If you liked this post, please share this?One "tiny" share from you would seriously help a lot with the growth of this blog. Some great suggestions:
- Pin it!
- Share it to your favorite blog + Facebook, Reddit
- Tweet it!