I have installed JDK 1.8 on my ubuntu 16.04, for some kind of work I had to install JDK 1.7.I installed it without did anything to my older version and changed the $JAVA_HOME to point the newly installed location.
$ java -version
Try to run following command in terminal:
$ sudo update-alternatives --config java
It shows installed alternatives for
java command. You can choose which one you will use by default further on.