2

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

Gilbert V
  • 1,050
  • 5
  • 16
  • 43
  • 1
    You need to tell it to open it with `Java.exe`. That's what that command is doing. – Carcigenicate Jan 16 '17 at 20:32
  • Java.exe not javaw.exe ? – Gilbert V Jan 16 '17 at 20:49
  • Afaik, it's java.exe. Again, afaik, `java -jar someJar.jar` just starts the `java` executable with the arguments `-jar someJar.jar`. I'd love to be corrected though. – Carcigenicate Jan 16 '17 at 22:22
  • It is definitely `javaw.exe`. java.exe will open a command window every time, which I doubt is desired behavior. – VGR Jan 16 '17 at 22:34
  • @VGR So are they the same, except the `-w` version doesn't have a persistent prompt open? I've always just used `java`, but ya, it does have a background prompt open for the lifetime of the program. – Carcigenicate Jan 16 '17 at 22:38
  • @Carcigenicate Correct. – VGR Jan 16 '17 at 22:54
  • If your program uses console I/O rather than (or in addition to) a GUI, you need `java.exe`; `javaw.exe` is for GUI-only programs. If you need the console display to remain after the program exits, so you can read the output for example, see http://stackoverflow.com/questions/10446986/double-clicking-jar-file-does-not-open-command-prompt or http://stackoverflow.com/questions/30540902/cant-open-jar-using-double-click-only-with-cmd – dave_thompson_085 Jan 17 '17 at 00:27

1 Answers1

2

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
jack jay
  • 2,493
  • 1
  • 14
  • 27
  • I tried this method, and for some reason it still isn't causing the .jar file to be executed and the .jar file in the description is not saying its an executable. – Gilbert V Jan 16 '17 at 20:53
  • Have a look at these [answers](http://stackoverflow.com/questions/394616/running-jar-file-on-windows) – jack jay Jan 16 '17 at 21:02
  • Would I need to do something with the registry on the windows machine as well? – Gilbert V Jan 26 '17 at 21:35
  • well darn, still nothing. Do you thinking uninstalling and reinstalling the JRE again would help fix this issue ? I am still wondering why a computer with java installed would not be configured to know what java means in command prompt. – Gilbert V Jan 27 '17 at 18:45
  • may something went wrong while installing java but you it should be the last option. – jack jay Jan 27 '17 at 18:47
  • I do not know what may be wrong with the computer , when a jre is installed it should by default associate jar files with java executables. but for some reason it jar files were set with WinRAR -.- – Gilbert V Jan 27 '17 at 19:00
  • 1
    well you gave me the best answer, I ended up updating the java version. but you did help a lot. so the points go to you Jack :) – Gilbert V Feb 09 '17 at 21:01