Environment Variable :
change(import) /etc/bashrc
export JAVA_HOME=/software/jdk1.8.0
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
save and exit.
Change default JDK:
update-alternatives --install /usr/bin/java java /software/jdk1.8.0/bin/java 300
update-alternatives --install /usr/bin/javac javac /software/jdk1.8.0/bin/javac 300
update-alternatiives --config java
[and then you can choose jdk version.]
Second Method: replace file
ln -s -f /usr/local/jdk1.6.0_24/jre/bin/java
ln -s -f /usr/local/jdk1.6.0_24/bin/javac
Test :
terminal: java -version