1

so I was trying to run my java app on a 64 bit Windows 7. I installed manually a 64 bit JRE and then I typed "java", "javaw" and "java -version" on the CMD prompt and it didn't recognize neither the "java" nor "javaw" command. Same thing with a 32 bit JRE.

I set manually the path where java was installed in environment variables and that seemed to do the trick. But why isn't that done automatically by the JRE installer? Or is there any easier way of doing that? I don't want to tell how to fix this to every person how uses my program... Thanks!

1 Answer 1

3

Installing java does install a windows shell extension. However java is designed to allow multiple versions running concurrent to each other and overwriting a global variable like PATH is just asking for trouble (especially if you install the older run-time after a newer run-time).

Your options are (In order of what I would do):

  1. Make your program work with launching it by double clicking on it from the shell.
  2. Compile a exe that launches the Jar (this is what Minecraft does)
  3. Create a shortcut that explicitly specifies java or javaw and pass your arguments.
  4. Include a launcher script that sets the all of the environment variables for the console you are running it inside but don't make them permanent.
  5. Create a installer that Modifies PATH.

Most people just go for option 1, but if you have to pass arguments you may have to do 3 or 4. I would suggest that you stay away from 5 as I like to write code that does not make global changes to the system.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .