Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Executing a Jar on Vista with a double click

This pretty much has me defeated.

On XP and earlier versions of Windows you could customise Open With filetypes to include java - jar "myjar.jar", but on Vista this functionality seems to have been removed. I can of course create a .bat file to launch my application, but is it possible to make Vista execute a .jar as required?

like image 256
Leonard H. Martin Avatar asked Dec 09 '08 23:12

Leonard H. Martin


People also ask

How do I run a .JAR file by double click?

Normally after installing Java, there will be an association between . jar and the javaw.exe. This enables the executable jar to be opened on double click. You can check the association by going to Control Panel -> Programs -> Default Programs -> Associate a file type or protocol with a program.

How do I run an executable jar from command line?

To run an application in a nonexecutable JAR file, we have to use -cp option instead of -jar. We'll use the -cp option (short for classpath) to specify the JAR file that contains the class file we want to execute: java -cp jar-file-name main-class-name [args …]


2 Answers

You can do it from the command line with 2 utilities.

The first one, ASSOC, is used to create a file association. To verify if there is one defined for JAR type :

>assoc .jar
.jar=jarfile

If not found then create it with :

>assoc .jar=jarfile

The next step is to define the association. This is done with FTYPE.

To verify if one is already defined , type

>ftype jarfile
jarfile="C:\Program Files\Java\jre1.5.0_10\bin\javaw.exe" -jar "%1" %*

Again if not found or the wrong JRE is used, use FTYPE to fix the problem

>ftype jarfile="C:\Program Files\Java\jre1.5.0_10\bin\javaw.exe" -jar "%1" %*
like image 162
RealHowTo Avatar answered Sep 30 '22 14:09

RealHowTo


Use the software JarFix >= 1.1.0 . There is Vista support included and it "recovers" the .jar association!

download for example here: http://www.softpedia.com/get/Others/Miscellaneous/Jarfix.shtml

like image 39
berlindev Avatar answered Sep 30 '22 12:09

berlindev