分类: LINUX
2019-07-28 10:27:56
[root@localhost src]# mkdir /usr/java #创建存放目录 [root@localhost src]# tar -zxvf jdk-8u131--x64.tar.gz #解压下载好的jdk [root@localhost src]# mv jdk1.8.0_131/ /usr/java #移动到创建的目录
以root用户,编辑系统全局环境配置文件/etc/profile
[root@localhost src]# vim /etc/profile 在/etc/profile文件尾部添加: export JAVA_HOME=/usr/java/jdk1.8.0_131 #jdk安装路径 export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH export CLASSPATH=$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$CLASSPATH.
[tomcat@localhost ~]$ vim .bash_profile #修改为下面的内容 # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi # User specific environment and startup programs JAVA_HOME=/usr/java/jdk1.8.0_131 #jdk安装路径 export JAVA_HOME
CLASSPATH=.:$JAVA_HOME/jre/lib/dt.jar:$JAVA_HOME/jre/lib/tools.jar
export CLASSPATH
PATH=$PATH:$HOME/bin:$JAVA_HOME/jre/bin
export PATH
export LANG=zh_CN.UTF-8
[tomcat@localhost ~]$ source /etc/profile
[tomcat@localhost ~]$ java -version
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)