Actually, you do not need to set the CLASSPATH and JAVA_HOME environment variables at all.
If you don't set the CLASSPATH, then Java will automatically look in the current directory for class files. You can also specify the classpath on the command line when you run a Java program by using the "-classpath" or "-cp" switch, for example:
java -cp C:\MyProject com.mycompany.MyProgram
The environment variable JAVA_HOME is not used at all by the JDK. Some other programs (like Apache
Tomcat) use it to determine the location of the Java runtime environment, but it is not really necessary.
Setting the PATH is optional, this is to tell your operating system where it should look for java.exe. If you don't add the "bin" directory your Java runtime environment to the PATH, you can still run Java programs, you'll just have to type in the full path of java.exe, for example:
C:\Java\jdk1.6.0_01\java -cp C:\MyProject com.mycompany.MyProgram
The
JDK installation notes explain how to set PATH on different versions of Windows.
To choose the JRE in Eclipse:
Goto the menu Window / Preferences..., choose Java / Installed JREs. There you can manage the JREs that you want to use with Eclipse and the projects you make in Eclipse. Also see the Eclipse help.
[ June 04, 2007: Message edited by: Jesper Young ]