Gilbert V
Gilbert V

Reputation: 1040

Java Windows. why can I run a jar file on command prompt but not double clicking it

Now on this machine earlier just typing in the command prompt: java

resulted in the command prompt saying java wasn't recognized. now the machine does have java installed , so I just added the java home and javahome/bin to path. and now pressing java causes java to be recognized but by double clicking a jar file, but I am not getting the software to run. But when I go to command prompt and type in the prompt "java -jar nameofJar.jar" the application runs fine. Not sure what is the issue. I added the environment variables to make sure it targets the jar file. I do notice something its not seeing the jar file as a "Executable jar file" simple a "jar file".

Upvotes: 2

Views: 1597

Answers (1)

jack jay
jack jay

Reputation: 2503

You have to tell java to execute your file with javaw.exe as told by @Carcigenicate

  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

Upvotes: 2

Related Questions