Resolving version conflict between java and javac on Ubuntu

Run either of the following to locate where the location is of that

javac 1.7.0_147

being used as follows:

whereis javac

or

 locate javac

or

find javac

Then once you found the directory, symbolically and forcefully link the bin contents to /usr/bin:

sudo ln -f -s [put location here]/bin/* /usr/bin

You will also need to do:

sudo update-alternatives --config javac

Select the desired java compiler from the list provided. For example on Centos 5

There are 2 programs which provide 'javac'.
Selection    Command
-----------------------------------------------
1           /usr/lib/jvm/java-1.6.0-openjdk/bin/javac
*+ 2        /usr/lib/jvm/java-1.7.0-openjdk/bin/javac

Type following command in terminal :

  sudo update-alternatives --config java

It will ask you for:

There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection      Path                                            Priority   Status

    0           /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java   1061      auto mode

    1           /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java   1061      manual mode

    2            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java  1051      manual mode


  Press enter to keep the current choice[*], or type selection number:

I enter 2 as I want to use java 1.7.0_21