老沙采用的环境是centos 6.5 64位服务器。在linux上安装jdk环境都很多中方式,这里讲解下手工进行安装并进行环境变量配置。
首先需要下载一个64位版本的linux,可以去oracle官网。如果懒得去找,可以直接执行:wget http://down.laosha.tk/common/jdk1.7.0_75.tar.gz 进行下载。
随后 cp jdk1.7.0_75.tar.gz /usr/local/
tar -xvf jdk1.7.0_75.tar.gz
注意以下必须使用root账号操作。
将JDK添加到环境变量 vi /etc/profile
在profile文件下面追加写入下面信息:
export JAVA_HOME=/usr/local/jdk1.7.0_75
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
保存退出,执行:source /etc/profile
此时可以执行java -version命令测试下,如果看到下图说明正常:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAc0AAAA2CAIAAAAqBVUkAAAJ9klEQVR4nO2dYZKsKgyFXZcLsuruxtW4GRbT90cLBHICwVbHnjlf3XrV0y0QAkZEc97079+/qWQN25L+mNfwyoR11l+3v5ymadnQkdvy/iCPjIcnA1LRXEFsZVvSr7Gq/aht28I62YhKtxBer7C2ehR/fX9ptZ5+Er4DxhfeCPl41HpR/H3Y/lVYp7J1WCcyCQ7HsuEOqcmQvpn11w1n50MtO6vDmkf6qesEHsXTG3jeGk09cI0ZQv4unTh7GXF+6raWdpTsMxAFSAccZ5dNXR0tPh5NQn4BKM7+xDVYLAwONp0XHO4gQBrs/jw0Gp+PJiG/CR1nCSGEnAnjLCGEXAvjLCGEXAvjLCGEXAvjLCGEXAvjLCGEXIuOs+r17u8h5T+cWN/rtS3xTf6d9xtP3YbKN9t7h/teasd1NtJGlPGEkNvherbFsqXEnhS/3rHckQshXtHvpU7kC0QnBQDXidLqsPGEkB8gx9kiBzFHhfz1fobHJVVYp3IVpo6EOIrnsPD+PaxLmTwhcmxDDDZ4PShtyomS72ROR0bDvIawTjG2SoZyzroZauJ3bwKVrBPHWdt4QsitoP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