-3

I have hello.jar which I want to execute by just specifying "hello.jar" or by double-clicking it and not by giving java -jar command. But this is not happening.

Below is the error that I am getting:-

enter image description here

As you can see from the above screenshot, java -jar hello.jar is working fine which means class path is not the problem.

Below is the structure of the JAR:- enter image description here

And the contents of the MANIFEST.MF are as follows:-

Manifest-Version: 1.0
Main-Class: hello.Main

Below are the details of my environment:- OS: Windows 7 Premium. Java: Java 7.

I have tried following approach as suggested by @Haloboy but it did not work:-

  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 to: C:\Program Files\Java\jre7\bin\javaw.exe for 32 bit Windows 7 or C:\Program Files (x86)\Java\jre7\bin\javaw.exe for 64 bit Windows 7
  6. Click the Open button
  7. Click the Ok button

Have tried solutins mentioned here and here but no success.

Any help/pointers on how to associate a JAR file with 'java -jar' will be helpful.

Community
  • 1
  • 1
Anuroop
  • 993
  • 3
  • 13
  • 25
  • first of all we can't see the error u are getting, but you simply need to change the default program that opens the .jar files [here is what you need](http://stackoverflow.com/questions/8511063/how-to-run-jar-file-by-double-click-on-windows-7-64) – QuakeCore Jun 17 '15 at 14:44
  • @QuakeCore The error that I am getting is already shown in the red square box above. – Anuroop Jun 18 '15 at 04:21

1 Answers1

0

You can get a JAR file to execute on a double click in Windows 7, via the following:

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 to: C:\Program Files\Java\jre7\bin\javaw.exe for 32 bit Windows 7 or
C:\Program Files (x86)\Java\jre7\bin\javaw.exe for 64 bit Windows 7

6.Click the Open button

7.Click the Ok button

AngelTrs
  • 236
  • 1
  • 8