Centos6.5 install jdk1.7 detailed steps

  

1, download jdk1.7 or use wget command to download directly

2, extract jdk

tar-axvf jdk-7u51-linux- X64.tar.gz

3. Configure environment variables

(1)Ordinary users

vim /home/user/.bash_profile

Add the following content :

export JAVA_HOME=/home/user/workspace/jdk/jdk1.7.0_51export PATH=$JAVA_HOME/bin:$PATH

(2)root user, configure global variables

vim /etc/profile

The added content is the same as above

4, making the configuration effective

source home/user/.bash_profile

5, view the java version

java -version

Note:

#Because sometimes the system default JDK is OpenJDK, so we need to modify, so that the system default JDK is Sun JDK

#Set java#sudo alternatives –install /usr/bin/java java /home/user/workspace/jdk/jdk1.7.0_51/jre/bin/java 20000

#设置javaws#sudo alternatives –install /usr/bin/javaws javaws /home/user/workspace/jdk/jdk1.7.0_51/jre/bin/javaws 20000

#Set javac#sudo alternatives & Ndash;install /usr/bin/javac javac /home/user/workspace/jdk/jdk1.7.0_51/bin/javac 20000

#Switch default JAVA#sudo alternatives –config java

Copyright © Windows knowledge All Rights Reserved