Sometimes it may be necessary to have two versions of java on your OSX, and to switch between the two in a fast,reliable and convenient manner. This post aims to show how this can be achieved.
I am currently using version 10.9.4 of OSX, and I was required to have both JAVA6 and JAVA7 on my system, as some of the codebases I was working on were dependent on JAVA6 and some were dependent on JAVA7.
Download the required jdk versions from Oracle downloads page.
After the installations are done, run the following command to know the java version currently being used.
Run the following command. Replace 1.6 with the version you want to switch to.
Export the output of the above code as JAVA_HOME as follows:
Now run the command to know the java version:
In this way, switching between the two versions can be done easily.
I am currently using version 10.9.4 of OSX, and I was required to have both JAVA6 and JAVA7 on my system, as some of the codebases I was working on were dependent on JAVA6 and some were dependent on JAVA7.
Download the required jdk versions from Oracle downloads page.
After the installations are done, run the following command to know the java version currently being used.
$java -version java version "1.7.0_67" Java(TM) SE Runtime Environment (build 1.7.0_67-b01) Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)
Run the following command. Replace 1.6 with the version you want to switch to.
$/usr/libexec/java_home -v 1.6 /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Export the output of the above code as JAVA_HOME as follows:
$export JAVA_HOME="/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home"
Now run the command to know the java version:
$java -version java version “1.6.0_65” Java(TM) SE Runtime Environment (build 1.7.0_67-b01) Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)
In this way, switching between the two versions can be done easily.
No comments :
Post a Comment