Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 347
coder Avatar asked Dec 14 '11 20:12

coder


People also ask

Can you double click a JAR file?

You need to run a Java Archive File (JAR) to execute a Java Runtime Environment (JRE) based application in a Windows 10, 11 or Windows Server environment. Double clicking the JAR file does not case any action or it does not work as expected and the Java application is not launched.

What is jar command option?

Options that control the jar command. jarfile. File name of the Jar file to be created ( c ), updated ( u ), extracted ( x ), or have its table of contents viewed ( t ). The -f option and filename jarfile are a pair -- if either is present, they must both appear.


3 Answers

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" %*
like image 119
AshUK Avatar answered Nov 11 '22 16:11

AshUK


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
like image 37
stratwine Avatar answered Nov 11 '22 15:11

stratwine


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

java.exe -jar file.jar
like image 21
Dariusz Woźniak Avatar answered Nov 11 '22 14:11

Dariusz Woźniak