码迷,mamicode.com
首页 > 编程语言 > 详细

Centos7.5 java环境的安装配置

时间:2016-09-06 15:09:50      阅读:269      评论:0      收藏:0      [点我收藏+]

标签:

1、查看系统中的java环境

  [root@localhost ~]# java -version
  openjdk version "1.8.0_101"
  OpenJDK Runtime Environment (build 1.8.0_101-b13)
  OpenJDK 64-Bit Server VM (build 25.101-b13, mixed mode)

  进一步查看JDK信息:

  [root@localhost ~]# rpm -qa | grep java
  javapackages-tools-3.4.1-11.el7.noarch
  java-1.8.0-openjdk-headless-1.8.0.101-3.b13.el7_2.x86_64
  python-javapackages-3.4.1-11.el7.noarch
  tzdata-java-2016f-1.el7.noarch
  java-1.8.0-openjdk-1.8.0.101-3.b13.el7_2.x86_64

  卸载 OpenJDK:rpm -e --nodeps

  [root@localhost ~]# rpm -e --nodeps javapackages-tools-3.4.1-11.el7.noarch
  [root@localhost ~]# rpm -e --nodeps java-1.8.0-openjdk-headless-1.8.0.101-3.b13.el7_2.x86_64
  [root@localhost ~]# rpm -e --nodeps python-javapackages-3.4.1-11.el7.noarch
  [root@localhost ~]# rpm -e --nodeps tzdata-java-2016f-1.el7.noarch
  [root@localhost ~]# rpm -e --nodeps java-1.8.0-openjdk-1.8.0.101-3.b13.el7_2.x86_64

2、安装jdk

  下载jdk的rpm安装包上传到/usr/local/java

  下载地址:http://www.oracle.com/technetwork/java/javase/downloads/index.html

技术分享

cd /usr/local/java 进入jdk所在的文件夹执行安装命令:

[root@localhost java]# rpm -ivh jdk-8u91-linux-x64.rpm
准备中...                          ################################# [100%]
正在升级/安装...
   1:jdk1.8.0_91-2000:1.8.0_91-fcs    ################################# [100%]
Unpacking JAR files...
    tools.jar...
    plugin.jar...
    javaws.jar...
    deploy.jar...
    rt.jar...
    jsse.jar...
    charsets.jar...
    localedata.jar...
    jfxrt.jar...

不报错就安装成功

验证:

[root@localhost java]# 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)

3、环境变量设置

修改系统环境变量文件
vi + /etc/profile

[root@localhost java]# vi + /etc/profile

fi

HOSTNAME=`/usr/bin/hostname 2>/dev/null`
HISTSIZE=1000
if [ "$HISTCONTROL" = "ignorespace" ] ; then
    export HISTCONTROL=ignoreboth
else
    export HISTCONTROL=ignoredups
fi

export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL

JAVA_HOME=/usr/java/jdk1.8.0_91
JRE_HOME=/usr/java/jdk1.8.0_91/jre
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
export JAVA_HOME JRE_HOME PATH CLASSPATH

# By default, we want umask to get set. This sets it for login shell
# Current threshold for system reserved uid/gids is 200
# You could check uidgid reservation validity in
# /usr/share/doc/setup-*/uidgid file
if [ $UID -gt 199 ] && [ "`id -gn`" = "`id -un`" ]; then
    umask 002
else
    umask 022
fi

for i in /etc/profile.d/*.sh ; do
    if [ -r "$i" ]; then
        if [ "${-#*i}" != "$-" ]; then
            . "$i"
        else
            . "$i" >/dev/null
        fi
    fi
done

unset i
unset -f pathmunge
"/etc/profile" 82L, 1972C

红色字体的为添加的设置,通常java安装在/usr/java/目录下

使修改生效
[root@localhost ~]# source /etc/profile   //使修改立即生效

验证配置:

[root@localhost java]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/java/jdk1.8.0_91/bin:/usr/java/jdk1.8.0_91/jre/bin

这样就完成的对整个java环境的配置

 

Centos7.5 java环境的安装配置

标签:

原文地址:http://www.cnblogs.com/java-qzq/p/5845509.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!