'Java' is not recognized as an internal or external command and program running

This is probably the most frequent question you get in the world, and I apologize, but I have to ask anyway. I recently downloaded the newest version of java (1.7.0_45-b18), and I recently finished making a small program for a local community of mine in Eclipse. I'd like to share it with them so anyone can run it by clicking it, but opening the jar file just hasn't seemed to work for me.

I attempted opening it with command prompt by using

java -jar StatCalc.jar

but it always tells me

'java' is not recognized as an internal or external command, operable program or batch file.

I looked up many solutions for this, the most common being to change your Path. So I went to the environment variables, and changed the path to

C:\Program Files (x86)\Java\jre7\bin\java.exe

But it still gives me the same result. Only when the directory is exactly in java, and the jar file is in the java bin folder can I run the program. I wan't any person to be able to run this.

How do I get command prompt to work and allow this program to be run by both me and other people in this small community?

Jon Skeet
people
quotationmark

The path shouldn't contain the executable itself - just the directory containing java.exe. So you want this on your path:

C:\Program Files (x86)\Java\jre7\bin

Restart your console, check that the path is correct (just run path and look at the output) and all should be well.

Note that if you're going to be developing Java code, you should probably use the JDK path instead of the JRE path. For example, my path contains c:\Program Files\Java\jdk1.7.0_17\bin. (Yes, I need to update :)

people

See more on this question at Stackoverflow