I have both 1.5 and 1.6 installed on my system.
I checked on console all programs were executed using 1.6 using command javac -version
But I want to run using 1.5...Is there any explicit cmd thorugh which I can change version at compile time..
If you are compiling from command prompt and your JDK 5 and 6 are in C:\Java5 and C:\Java6 respectively, then you can try this from command prompt
C:\Java5\bin\javac abc.java for 1.5
C:\Java6\bin\javac abc.java for 1.6 (or without it as its your default version)
I ***think*** it should work.
If using IDE, select the JDK of choice while creating project.
If I become filthy rich, I'll sponsor research for painless dental treatment at Harvard Medical School. Thats why,I'm learning Java.I have 32 teeth, 22 are man made.
nitude, Jhakda is right. You can install multiple versions of Java on your system at the same time. Usually setting the path environment variable to point to one of the version of java is the preferred way of using a specific java version but you can use the solution Jhakda gave too...
You write something like
set PATH=C:\program files\java\jdk1.4.2_12\bin;%PATH%
at the command line (that syntax only works for Window: for *nix try export PATH=/usr/java/jdk1.4.2_12/bin:$PATH). I think it is "Set" but may be mistaken. Windows is case-insensitive, *nix is case-sensitive.
That should reset your PATH for that terminal/command prompt only. Putting a particular JDK first in the PATH forces the computer to use that particular version of the java.exe program.
subject: How to use different java versions on my machine