Sunday, December 7, 2008

Switch between different JDK versions in Windows

Being a Java developer, I always compile and test my code on different Java versions. But switching between them is a huge problem. So finally I found an easy method to do this. You have to create following batch files and place them in directory you open your command line in or in SYSTEM PATH. You can use you favorite text editor to create these files.

jdk14.bat
@echo off
echo Setting JAVA_HOME
set JAVA_HOME=C:\j2sdk1.4.2_12
echo setting PATH
set PATH=C:\j2sdk1.4.2_12\bin;%PATH%
echo Display java version
java -version

jdk15.bat
@echo off
echo Setting JAVA_HOME
set JAVA_HOME=C:\Program Files\Java\jdk1.5.0_12
echo setting PATH
set PATH=C:\Program Files\Java\jdk1.5.0_12\bin;%PATH%
echo Display java version
java -version

jdk16.bat
@echo off
echo Setting JAVA_HOME
set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_11
echo setting PATH
set PATH=C:\Program Files\Java\jdk1.6.0_11\bin;%PATH%
echo Display java version
java -version

Make sure you assign the appropriate JAVA_HOME value in batch files, according to your Java installation. Whenever you want to switch between Java versions, just run the respective batch file and you are done.

Note- JAVA_HOME and the path to java must always refer to the exact same version of the JDK. If you mix them up, unpredictable things will happen!

Saturday, December 6, 2008

Hello World!

Hello World! Welcome to my new blog. I am Pranav Prakash, currently working as Associate Applications Engineer at Oracle India Pvt. Ltd. in Peoplesoft Enterprise Tools division. I have completed my B. Tech. in Electrical Engineering from IIT Kharagpur in May 2008. Since then I'm working for Oracle. Up till now, my stay at Oracle has been very much knowledge enriching. I would be posting tips, tricks and work-arounds which I have learned from my experiences in this blog.