在7上安装JDK1.8
1、下载jdk的rph版本;
2、rz命令上传到centos;
3、rpm -ivhjdk-7u79-linux-x64.rpm
1 通过 SecureCRT 连接到阿里云 CentOS7 服务器;
2 进入到目录 /usr/local/ 中:
cd /usr/local/3 创建目录 tools:
mkdir -p tools4 进入到目录 /usr/local/tools 中:
cd tools/5 下载 jdk-8u91-linux-x64.tar.gz:
wget --no-check-certificate --no-cookies --header "Cookie: license=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/7u71-b14/jdk-7u71-linux-x64.rpm wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u91-b14/jdk-8u91-linux-x64.tar.gz wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u91-b14/jdk-8u91-linux-x64.rpm wget --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie;" http://download.oracle.com/otn-pub/java/jdk/7u65-b17/jdk-7u65-linux-x64.tar wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.2.6.tgz wget http://download.redis.io/releases/redis-3.0.7.tar.gz wget http://mirror.bit.edu.cn/apache/tomcat/tomcat-9/v9.0.0.M4/bin/apache-tomcat-9.0.0.M4.tar.gz wget http://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.12-1.el7.x86_64.rpm-bundle.tar wget http://apache.fayea.com/zookeeper/zookeeper-3.4.8/zookeeper-3.4.8.tar.gz wget http://memcached.org/files/memcached-1.4.25.tar.gz6 加压缩 jdk-8u91-linux-x64.tar.gz 文件:
tar -zxvf jdk-8u91-linux-x64.tar.gz7 返回到上一级并创建 /usr/local/jdk 目录:
cd .. mkdir -p jdk8 进入到 tools 目录后将 jdk1.8.0_91 移动到 jdk 目录中:
cd ../tools/ mv jdk1.8.0_91/ ../jdk/9 打开 /etc/ 目录下的 profile 文件:
vi /etc/profile 将如下代码追加到 profile 文件末尾: # idea - jdk8 settings start 2016-05-01JAVA_HOME=/usr/local/jdk/jdk1.8.0_91
JRE_HOME=$JAVA_HOME/jre PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin CLASSPATH=:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib/dt.jar export JAVA_HOME JRE_HOME PATH CLASSPATH# idea - jdk8 settings end - 2016-05-01
按 Esc 键、输入 :wq! 回车,保持并退出。10 即可启用新的配置:
source /etc/profile11 输入 java -version 查看 JDK 的版本:
[root@iZ94hws2fzlZ jdk1.8.0_91]# java -version java version "1.8.0_91" Java(TM) SE Runtime Environment (build 1.8.0_91-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)
异常处理:
1、报错误:-bash: /etc/profile: Permission denied
处理方法:可以修改文件夹权限,例如:chmod +x /usr/java/jdk1.7.0_79/bin/java
2、错误:/etc/profile: fork: Cannot allocate memory