I had the same issue, So I figured it out with the simple command for Ubuntu to fix the things.
Steps that I followed are as:
1. Open Terminal
2. Run command : sudo update-alternatives --config java
3. It will give you options like this:
There are 2 choices for the alternative java (providing /usr/bin/java). Selection Path Priority Status ------------------------------------------------------------ * 0 /usr/lib/jvm/java-6.31-oracle/bin/java 1062 auto mode 1 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 manual mode 2 /usr/lib/jvm/java-6.31-oracle/bin/java 1062 manual mode Press enter to keep the current choice[*], or type selection number:
Now we have to just select the number for the java version to make it default.
#Cheers Enjoy Learning