Skip to main content

How to switch between java versions in linux?



How to switch between java versions in linux? (older or newer version selection).

1. First check what  is the version is already been installed on your host by issuing command

$java -version

then you will see something like below


OpenJDK Runtime Environment (build 1.6.0-b09)
OpenJDK Client VM (build 1.6.0-b09, mixed mode)
This gives you the current version of java you are using.

2.If you have more than one java versions installed on host then enter following command
$update-alternative --config java
this will give you the following output
1. /usr/lib/jvm/jre-1.4.2-gcj/bin/java
*+ 2 /usr/lib/jvm/jre-1.6.0-openjdk/bin/java
Enter to keep the current selection[+], or type selection number:
Here the * indicates currently which java version you are using. you can input selection number to switch between two.

Thanks,
Shrenik.
Have a look on my interview with EEWeb online international community






Comments