When I run java -version in my terminal I get:user@ubuntu:~$ java -versionjava version 1.7.0_25OpenJDK Runtime Environment (IcedTea 2.3.10) (7u25-2.3.10-1ubuntu0.13.04.2)OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)I need to change my java to 5. I have downloaded jdk5 which is located here:/home/user/tools/jdk1.5.0_22First I have tried to add the following to my ~/.bashrc file:JAVA_HOME=/home/user/tools/jdk1.5.0_22export JAVA_HOMEPATH=$PATH:$JAVA_HOME/binexport PATH I have then restarted my terminal but I still get:user@ubuntu:~$ java -versionjava version 1.7.0_25OpenJDK Runtime Environment (IcedTea 2.3.10) (7u25-2.3.10-1ubuntu0.13.04.2)OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)I have then tried to add JAVA_HOME to /etc/environment :PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/gamesJAVA_HOME=/home/user/tools/jdk1.5.0_22After restarting the terminal (close and open a new one) java still points to jdk 7:user@ubuntu:~$ java -versionjava version 1.7.0_25OpenJDK Runtime Environment (IcedTea 2.3.10) (7u25-2.3.10-1ubuntu0.13.04.2)OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)But it seems that the JAVA_HOME is set:user@ubuntu:~$ echo $JAVA_HOME/home/user/tools/jdk1.5.0_22How do I change the version of java that I use?
Cannot change JAVA_HOME
path;java
The first java executable found in your PATH is /usr/bin/java, which is probably a link to /etc/alternatives/java which is probably a link to /usr/lib/jvm/java-7-oracle/jre/bin/java.You can try setting your PATH to have your new java location in the beginning. You did the opposite by adding it in the end. You should have tried the following:export PATH=/home/user/tools/jdk1.5.0_22/bin:$PATHIn combination with JAVA_HOME you should be OK, but another more debian-ish (or ubuntu-ish) way is to use the update-alternatives utility.sudo update-alternatives --install /usr/bin/java java /home/user/tools/jdk1.5.0_22/bin/java 100sudo update-alternatives --set java /home/user/tools/jdk1.5.0_22/bin/javaBut you need to do this with all executable files you intent to use from that installation.For more details see https://askubuntu.com/q/159575/11831