简体   繁体   中英

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".

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM