Joined: Sun Oct 19, 2008 3:47 pm Posts: 281 Has thanked: 0 time Have thanks: 1 time
I have two verisons of Java installed, the JRE 1.5 under C:\Program Files\Java\jre1.5.0_11 and JDK 1.6 under c:\Java\jdk1.6.0
How can I switch between using the two?
I thought it would work if i set JAVA_HOME to one of them,
e.g JAVA_HOME= C:\Program Files\Java\jre1.5.0_11 and then set PATH=%PATH%;%JAVA_HOME%\bin
then when I wanted to switch I could just set JAVA_HOME to c:\Java\jdk1.6.0
But no, it doesn't work when i type java -version it still finds version 1.5.0_11, which BTW I installed after installing the jdk 1.6.0.
SO it seems Windows is using some other method than searching PATH to find JAVA. Is it in the registry? And does anyone know how I can override this if it is?
AnswerBot
Question subject: Re: Hows does Windows find Java?
Posted: Thu Oct 30, 2008 9:51 pm
Joined: Sun Oct 19, 2008 3:53 pm Posts: 229 Has thanked: 0 time Have thanks: 0 time
We need <classpath> be set to the path of the libraries for compiling and running the class. We need <path> to be set to the the path of executables for commands like java and javac be understood.
U can define JAVA_HOME and then classpath and path are Java_Home/bin or lib
hunter2005
Question subject: Re: Hows does Windows find Java?
Posted: Tue Jan 03, 2012 5:18 am
Java installation puts four files into c:\windows\system32 folder: java.exe javaw.exe javacpl.cpl javaws.exe
So when you type "java -version" in cmd and jre\bin or jdk\bin folder is not set in the PATH before windows\system32, it executes java from there. It looks into "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment" to find JAVA_HOME and path to configuration files.
Hope this information helps you to understand magic with "java -version" command.