环境:RHEL 7.1 + Oracle JDK 1.7.0_80 + PostgreSQL 9.1
3. 安装 Oracle JDK
下载地址:http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
安装介质:jdk-7u80-linux-x64.tar.gz
切换到 root 用户执行如下命令:
(1)mkdir -p /opt/jbshome/java
(2)cd /opt/jbshome/java
(3)tar -zxvf jdk-7u80-linux-x64.tar.gz
(4)vim /etc/profile
在文件最后增加如下内容:
#Set Java Environment
export JAVA_HOME=/opt/jbshome/java/jdk1.7.0_80
export CLASSPATH=.:$JAVA_HOME/lib.tools.jar
export PATH=$JAVA_HOME/bin:$PATH
(5)source /etc/profile
(6)java -version
java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)
说明JDK环境配置正确。
(7)重新打开一个终端,执行 java -version
java version "1.7.0_75"
OpenJDK Runtime Environment (rhel-2.5.4.2.el7_0-x86_64 u75-b13)
OpenJDK 64-Bit Server VM (build 24.75-b04, mixed mode)
发现JDK还是没改过来。
(8)检查当前的java环境
# which java
/bin/java
# ll /bin/java
lrwxrwxrwx. 1 root root 22 12月 21 20:45 /bin/java -> /etc/alternatives/java
# ll /etc/alternatives/java
lrwxrwxrwx. 1 root root 74 12月 21 20:45 /etc/alternatives/java -> /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.75-2.5.4.2.el7_0.x86_64/jre/bin/java
(9)将系统默认的jdk修改过来
# update-alternatives --install /usr/bin/java java /opt/jbshome/java/jdk1.7.0_80/bin/java 300
# update-alternatives --install /usr/bin/javac javac /opt/jbshome/java/jdk1.7.0_80/bin/javac 300
# update-alternatives --config java
共有 2 个提供“java”的程序。
选项 命令
-----------------------------------------------
*+ 1 /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.75-2.5.4.2.el7_0.x86_64/jre/bin/java
2 /opt/jbshome/java/jdk1.7.0_80/bin/java
按 Enter 保留当前选项[+],或者键入选项编号:2
# update-alternatives --config javac
共有 1 个提供“javac”的程序。
选项 命令
-----------------------------------------------
*+ 1 /opt/jbshome/java/jdk1.7.0_80/bin/javac
按 Enter 保留当前选项[+],或者键入选项编号:1
(10)重新打开一个终端,执行 java -version
java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)
至此,JDK安装并配置完毕。
3. 安装 Oracle JDK
下载地址:http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
安装介质:jdk-7u80-linux-x64.tar.gz
切换到 root 用户执行如下命令:
(1)mkdir -p /opt/jbshome/java
(2)cd /opt/jbshome/java
(3)tar -zxvf jdk-7u80-linux-x64.tar.gz
(4)vim /etc/profile
在文件最后增加如下内容:
#Set Java Environment
export JAVA_HOME=/opt/jbshome/java/jdk1.7.0_80
export CLASSPATH=.:$JAVA_HOME/lib.tools.jar
export PATH=$JAVA_HOME/bin:$PATH
(5)source /etc/profile
(6)java -version
java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)
说明JDK环境配置正确。
(7)重新打开一个终端,执行 java -version
java version "1.7.0_75"
OpenJDK Runtime Environment (rhel-2.5.4.2.el7_0-x86_64 u75-b13)
OpenJDK 64-Bit Server VM (build 24.75-b04, mixed mode)
发现JDK还是没改过来。
(8)检查当前的java环境
# which java
/bin/java
# ll /bin/java
lrwxrwxrwx. 1 root root 22 12月 21 20:45 /bin/java -> /etc/alternatives/java
# ll /etc/alternatives/java
lrwxrwxrwx. 1 root root 74 12月 21 20:45 /etc/alternatives/java -> /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.75-2.5.4.2.el7_0.x86_64/jre/bin/java
(9)将系统默认的jdk修改过来
# update-alternatives --install /usr/bin/java java /opt/jbshome/java/jdk1.7.0_80/bin/java 300
# update-alternatives --install /usr/bin/javac javac /opt/jbshome/java/jdk1.7.0_80/bin/javac 300
# update-alternatives --config java
共有 2 个提供“java”的程序。
选项 命令
-----------------------------------------------
*+ 1 /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.75-2.5.4.2.el7_0.x86_64/jre/bin/java
2 /opt/jbshome/java/jdk1.7.0_80/bin/java
按 Enter 保留当前选项[+],或者键入选项编号:2
# update-alternatives --config javac
共有 1 个提供“javac”的程序。
选项 命令
-----------------------------------------------
*+ 1 /opt/jbshome/java/jdk1.7.0_80/bin/javac
按 Enter 保留当前选项[+],或者键入选项编号:1
(10)重新打开一个终端,执行 java -version
java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)
至此,JDK安装并配置完毕。
没有评论:
发表评论