How to run .jar file by double click on Windows 7 64-bit?
Asked Answered
C

20

89

Running a .jar file in a command line works fine, but i am not able to run any .jar file by double clicking on my Windows 7 (64). It seems nothing happens after the double click.

I tried the ftype hint, no success:

ftype jarfile="C:\Program Files\Java\jre7\bin\javaw.exe" -jar "%1" %*

I reinstalled the JDK 7 64-bit, no success.

Any idea?

Corcyra answered 14/12, 2011 at 20:17 Comment(5)
It sounds like you're doing everything right. Please take a look at my link below. And please make sure 1) "c:\Program files\java\jre7\bin\javaw.exe" is the correct path, and 2) that path is also defined correctly under "HKLM, Software, Java" in your registry.Adriaadriaens
the ftype command also needs to be run as an administrator.Amblygonite
possible duplicate of Running Jar file in WindowsVostok
The real answer is that you need to use something like packr or one-jar that will extract and execute your code for the user, or build to a JNLP file which Java now properly associates.Melvin
Having the issue myself, I created an application to do just this. It locates the java installation, runs the appropriate executable (JavaW.exe), and directs it to the JAR file. 'Really simple coding but also really handy too. The link may be found in my comment below. =) #8511563Campion
E
39

What is listed in right-click-> Open With ? Is some other program listed as the default program ? Is a Java Runtime listed ? If a Java Runtime is listed, you can open with it, and make it the default program to run with.

ie,

Right Click ->  Properties -> Change -> C:\Program Files\Java\jre7\bin\javaw.exe
Elevenses answered 14/12, 2011 at 20:35 Comment(4)
This doesn't appear to work in java 8. Thus far my only success has been to run from command line: java.exe -jar myFile.jarPickett
Same here - a double click on a file associated with javaw results in nothing. Manually running on the command line works.I guess the associated one doesn't put in the -jar ?Chipboard
Double-click functionality is possible through use of an external script - either a BATch file or an EXEcutable. I compiled just such an executable for use on my machine since Windows 10 seems to have neglected to associated JAR files as well. See the following comment: #8511563Campion
So you are saying it is impossible to just double click a JAR for it to work? without a BATch file or an EXE?Audre
A
60

If you have previously used the right click and opened with \path\to\your\javaw.exe then you will need to remove the following registry key.

[-HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.jar]

Then run

C:\>assoc .jar=jarfile
C:\>ftype jarfile="C:\path\to\your\javaw.exe" -jar "%1" %*
Ampulla answered 1/6, 2015 at 10:36 Comment(3)
I used ftype jarfile="C:\path\to\your\java.exe" -jar "%1" %* to make it work.Checkers
@Shifatullah the only difference afaik is that java is linked to a console whereas javaw is notEskill
Remember to restart Windows File Explorer to see the changes take effectCosgrove
E
39

What is listed in right-click-> Open With ? Is some other program listed as the default program ? Is a Java Runtime listed ? If a Java Runtime is listed, you can open with it, and make it the default program to run with.

ie,

Right Click ->  Properties -> Change -> C:\Program Files\Java\jre7\bin\javaw.exe
Elevenses answered 14/12, 2011 at 20:35 Comment(4)
This doesn't appear to work in java 8. Thus far my only success has been to run from command line: java.exe -jar myFile.jarPickett
Same here - a double click on a file associated with javaw results in nothing. Manually running on the command line works.I guess the associated one doesn't put in the -jar ?Chipboard
Double-click functionality is possible through use of an external script - either a BATch file or an EXEcutable. I compiled just such an executable for use on my machine since Windows 10 seems to have neglected to associated JAR files as well. See the following comment: #8511563Campion
So you are saying it is impossible to just double click a JAR for it to work? without a BATch file or an EXE?Audre
C
21

You may also run it from the Command Prompt (cmd):

java.exe -jar file.jar

I know this is not an answer for the double-click, but it might save time for some.

Call answered 21/12, 2012 at 23:55 Comment(0)
W
19

I tried all above steps to resolve the problem but nothing worked. I had installed both JDK and JRE.

In my case, one jar file was being opened by double click while other was not being opened. I examined those files and the probable reason was that which was being opened, was created using JAVA SE 6 and the one not being opened was created using JAVA SE 7. Although, the problematic jar file was being run via command prompt (java -jar myfile.jar).

I tried Right Click -> Properties -> Change to javaw.exe with both in JDK\bin directory and JRE\bin directory.

I was finally able to fix the problem by changing javaw.exe path (from JDK\bin to JRE\bin) in registry editor.

Go to HKEY_CLASSES_ROOT\jarfile\shell\open\command, the value was,

"C:\Program Files\Java\jdk-11.0.1\bin\javaw.exe" -jar "%1" %*

I changed it to,

"C:\Program Files\Java\jre1.8.0_191\bin\javaw.exe" -jar "%1" %*

and it worked. Now the jar file can be opened by double click.

Welter answered 24/10, 2018 at 3:12 Comment(5)
This should be the accepted answer. None of the other answers worked for me in Windows 10. They may work in Windows 7 though.Contentment
This worked for me. None of the other methods worked. This key in registry had some old version of Java which prevented opening the Jar by double clicking the file.Utile
My association in Windows 10 was HKEY_CLASSES_ROOT\.jar_auto_file\shell\open\command and used "C:\dev\openjdk11\bin\javaw.exe" -jar "%1"Hohenstaufen
Changing the value of jarfile did not work on Win7. Do what @Hohenstaufen said. Changing the value of jar_auto_file immediately worked.Underpin
This+CodeMonkey's answer worked for me, though it wasn't jarfile in the registry editor, it was jar_auto_file. Thanks! https://mcmap.net/q/236133/-how-to-run-jar-file-by-double-click-on-windows-7-64-bitNormalie
R
16

For Windows 7:

  1. Start "Control Panel"
  2. Click "Default Programs"
  3. Click "Associate a file type or protocol with a specific program"
  4. Double click .jar
  5. Browse C:\Program Files\Java\jre7\bin\javaw.exe
  6. Click the button Open
  7. Click the button OK
Rovner answered 17/3, 2012 at 19:39 Comment(4)
For Windows 7 or 8 64-bit: Step 5: C:\Program Files (x86)\Java\jre7\bin\javaw.exeScrofulous
This may sound daft, but what might be the issue if ".jar" doesn't appear in the list (step 4)?Idyllic
this doesn't work for me. I am running windows 7 64, and just reinstalled java jdk1.7.0_45. If I open a command prompt and run java -jar filename.jar, it runs fine, but associating the jar file to javaw, java, or javaws all fail with no error message.Corvin
Having the issue myself, I created an application to do just this. It locates the java installation, runs the appropriate executable (JavaW.exe), and directs it to the JAR file. 'Really simple coding but also really handy too. The link may be found in my comment below. =) #8511563Campion
B
14

If you try unpopular's answer:

For Windows 7:

  1. Start "Control Panel"
  2. Click "Default Programs"
  3. Click "Associate a file type or protocol with a specific program"
  4. Double click .jar
  5. Browse C:\Program Files\Java\jre7\bin\javaw.exe
  6. Click the button Open
  7. Click the button OK

And jar files still fail to open (in my case it was like I never double clicked):
open the Command Prompt (to be safe with admin rights enabled) and type the following commands:

java -version This should return a version so you can safely assume java is installed.

Then run

java -jar "PATHTOFILE\FILENAME.JAR"

Read through the output generated. You may discover an error message.

Bunnybunow answered 21/11, 2013 at 16:41 Comment(2)
and for XP, what should i do?Luciolucita
in my case it doesn't change anything, only go back to system32Titration
M
6

I had the same problem with .jar files not opening on a double click. It turned out that I had two versions of Java installed (Java 6 and 7). Uninstalling Java 6 from Control Panel-> Uninstall a Program was what finally allowed .jar files to open on a double click without using the command window.

Michel answered 8/8, 2012 at 14:8 Comment(1)
That's absolutely right, it happened to me and after I read your solution it worked againArchilochus
G
4

I had the same issue: if I doubleclick on a jar executable file, and my Java application does not start.

So tried to change manually also registry key, but it didn't help me. Tried to reinstall JDK newer/older without any result. (I have several versions of Java)

And I've solved it only using jarfix program. Jarfix automatically fixed .jar association problem on Windows system. (check regedit: PC\HKEY_CLASSES_ROOT\jarfile\shell\open\command)

What says Johann Nepomuk Löfflmann:

The root cause for the problem above is, that a program has stolen the .jar association. If you have installed the Java Runtime Environment the first time, the file type called "jar" is assigned to javaw.exe correctly. "jar" is an abbreviation for "java archive" and javaw.exe is the correct program to execute a .jar. However, on Windows any program can steal a file type at any time even if it is already associated with a program. Many zip/unzip programs prefer to do this, because a jar is stored in the .zip format. If you doubleclick on a .jar, your pack program opens the file, rather than javaw runs the program, because your pack program ignores the meta information which are also stored in a .jar. In the Oracle bug database there is the low-priority report 4912211 "add mechanism to restore hijacked .jar and .jnlp file extensions", but it has been closed as "Closed, Will Not Fix".

You may also miss the file connection with .jar if you are using a free OpenJDK without an installer.

Notice: my OS is Windows 10, but logic is the same for 7, 8 and so on.

Helpful links:
https://windowsreport.com/jar-files-not-opening-windows-10/ https://johann.loefflmann.net/en/software/jarfix/index.html

Goalie answered 13/8, 2019 at 15:33 Comment(0)
T
3

This is my way:

  1. Create file bat (example openJar.bat).

    @echo off
    start javaw -jar "%1" %*
    exit
    
  2. Cut it and paste to C:\Program Files\Java\\bin (this step is unnecessary, but you should it).

  3. Right click jar file > Properties > Choose open with (Change button ) and select your file bat.
  4. Double click your jar file to test it.
Turfy answered 1/5, 2018 at 2:8 Comment(0)
E
2

I had the problem that windows was blocking it from running (Windows 10 Pro). Right click icon> properties> in the bottom right corner it might tell you "Windows has blocked the functionality........" next to it there is a check box labeled "Unblock"> uncheck the box> apply> option to block goes away and then you can run it.

Equip answered 1/12, 2015 at 21:22 Comment(1)
This+ePandit's answer worked for me. Thanks! https://mcmap.net/q/236133/-how-to-run-jar-file-by-double-click-on-windows-7-64-bitNormalie
A
1

http://www.wikihow.com/Run-a-.Jar-Java-File

  1. Assuming you've loaded the Java JRE and/or Java SDK, then
  2. To do associations, go to "My Computer", click on one of your drives (C: for instance).
  3. When it is shown, choose "Tools" »» "Folder options" (or Properties... it's in different places depending on the Windows version).
  4. Open Windows Explorer (just open any folder) to get the "Tools" -> "Folder options" window.
  5. When you get the "Folder options" window, click on the tab "File types". You should be able to either edit or add JAR files (.jar extension)
  6. Change the program used to open JAR files. In the file select window, go to the folder where the JRE is installed (should be C:/Program Files/Java/..., mark "Always open with", and select the javaw.exe file.
Adriaadriaens answered 14/12, 2011 at 20:23 Comment(0)
J
1

Your problem might also be inside your Java code setting, I mean, if your program somehow could not realize the main class/main file (entry point), it will not launch the the program/.jar (specially application built on IDE's). To solve that on an IDE :

  • Right Click the project > Properties > Run > Browse Main Class > OK.
  • Clean and Rebuild

Try running it now. Hope it helps

Jeggar answered 15/5, 2015 at 7:5 Comment(0)
C
1

I created a project, JAR_Runnr, for precisely this. =)

http://projects.killerapplets.com/JAR_Runner/

Campion answered 12/2, 2016 at 18:41 Comment(0)
T
1

change the default application for JAR files from java.exe to javaw.exe from your JAVA_HOME/bin folder.

This is because, java.exe is console application only, but JAR file needs a window rendered execution. Since javaw.exe is a window application, it is preferred for the execution of JAR files.

An alternative to this is that to some extent you can use command prompt to run your JAR files by simply using java keyword with -jar attrib.

Tatia answered 6/6, 2016 at 13:56 Comment(0)
M
1

In Windows 10, I used: The JAVA_HOME instead!

I renamed Computer\HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.jar to Computer\HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.jar_BACK

And I used:

assoc .jar=jarfile
ftype jarfile="%JAVA_HOME%\bin\javaw.exe" -jar "%1" %*
Memorize answered 29/3 at 21:45 Comment(0)
S
0

Installing the newest JRE fixed this for me.

(Even though I had a JDK and JRE(s) installed before.)

Susceptive answered 20/2, 2015 at 3:3 Comment(0)
W
0

It's not a file association problem since you can launch the application correctly through command line.

The problem is when you double click on an associated file the application starts and runs with the file's path as base execution path. Any relative path will be computed from the file path and everything you try to load will probably be missing.

Nothing happens, even if you surround all of your entry point code with try/catch(Exception) because java s throwing Throwables and not Exceptions: to fix this in your java entry point surround the content of the main method with a try/catch(Throwable) (base class for Exception and Error) and debug.

Washboard answered 29/7, 2015 at 9:9 Comment(0)
I
0

Had to try this:

  1. Open command prompt as admin
  2. Move to the file folder using cd command
  3. Type java.exe -jar *filename*.jar
  4. Press enter

The app should pop right after that.

Igniter answered 8/8, 2018 at 7:28 Comment(0)
C
0

I had this same issue, and searched the internet for a solution and none of the suggestions didn’t not 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:

  1. Create a shortcut for the .jar file that you want to open.
  2. Right click the shortcut icon and select properties -> Shortcut tab
  3. Change the text in the target (for example "D:\Dev\JavaApp1.8.jar") To

    "C:\Program Files\Java\jdk1.8.0\bin\javaw.exe" -jar "D:\Dev\JavaApp1.8.jar"

  4. Then click ok Double click the shortcut.

It should now open the app.

Carburize answered 28/5, 2019 at 3:21 Comment(0)
T
0

To run jar file by double click (in windows): Open cmd and write:

assoc .jar

you should get:

.jar=jarfile

then write:

ftype jarfile

you should get something like this:

jarfile="C:\Program Files\Java\jdk-20\bin\javaw.exe" -jar "%1" "%*"

then write this:

ftype JARFile="C:\Program Files\Java\jdk-20\bin\javaw.exe" -jar --module-path "C:\Program Files\Java\javafx-sdk-20\lib" --add-modules javafx.controls,javafx.fxml "%%1" "%%*"

Replace JARFile path with your path to javaw.exe, and modul-path with your path to javafx lib. If you are using NetBeans, Eclipse or IntelliJ, after -jar those are VM arguments/options you had to write to run it from application. You can write/copy it to notepad and save it with extension .bat (anyName.bat) right click and run it as administrator. Now if you write again:

ftype jarfile

you should get:

jarfile="C:\Program Files\Java\jdk-20\bin\javaw.exe" -jar --module-path "C:\Program Files\Java\javafx-sdk-20\lib" --add-modules javafx.controls,javafx.fxml "%1" "%*"

and it should work, on your computer. Notice double % and then single. The percent signs are doubled to escape them, because a single percent has a special meaning within a batch file. More about it here: https://ss64.com/nt/ftype.html

Tyrothricin answered 18/5, 2023 at 9:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.