First of all, go to Sun/Oracle Java official page: http://www.oracle.com/technetwork/java/javase/downloads/index.html.
Find the version you want to install and download it. For me, I download jdk-7u21-linux-x64.tar.gz and uncompress it to /usr/lib/jvm. So my JDK installation home directory is /usr/lib/jvm/jdk1.7.0_21.
Set up the environment:
$sudo gedit /etc/environment and add the following content to the end of the file.
JAVA_HOME=/usr/lib/jvm/jdk1.7.0_21
PATH=$PATH:$JAVA_HOME/bin
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$CLASSPATH
export JAVA_HOME PATH CLASSPATH
$source /etc/environment
Set Sun JDK as default
$sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0_21/bin/java 300
$sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.7.0_21/bin/javac 300
$sudo update-alternatives --config java
Select the right number.
Verify it:
$java -version
$javac -version
Sometimes we need to run jps command (list all daemons to verify the hadoop setup)
install it: sudo update-alternatives --install /usr/bin/jps jps $JAVA_HOME/bin/jps 1
Then you can run $jps rather than $JAVA_HOME/bin/jps
Done
No comments:
Post a Comment