Java2 codes,problems ,discussions and solutions are here
Thu Oct 30, 2008 9:50 pm
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?
Thu Oct 30, 2008 9:51 pm
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
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.
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.