CentOS7安装JDK8


本文摘自CSDN,原文地址:https://blog.csdn.net/music0ant/article/details/89818633,侵删。

1. 检查系统中的jdk版本


java -version

显示:

openjdk version "1.8.0_102"

OpenJDK Runtime Environment (build 1.8.0_102-b14)

OpenJDK 64-Bit Server VM (build 25.102-b14, mixed mode)


2. 查询自带的openjdk


rpm -qa | grep -i java

显示:

java-1.7.0-openjdk-1.7.0.111-2.6.7.8.el7.x86_64

java-1.8.0-openjdk-1.8.0.102-4.b14.el7.x86_64

java-1.8.0-openjdk-headless-1.8.0.102-4.b14.el7.x86_64

java-1.7.0-openjdk-headless-1.7.0.111-2.6.7.8.el7.x86_64


3. 卸载openjdk


rpm -e --nodeps java-1.7.0-openjdk-1.7.0.111-2.6.7.8.el7.x86_64

rpm -e --nodeps java-1.7.0-openjdk-headless-1.7.0.111-2.6.7.8.el7.x86_64

rpm -e --nodeps java-1.8.0-openjdk-1.8.0.102-4.b14.el7.x86_64

rpm -e --nodeps java-1.8.0-openjdk-headless-1.8.0.102-4.b14.el7.x86_64


或者使用

yum remove *openjdk*

之后再次输入rpm -qa | grep java查看卸载情况

4. 检查系统环境


uname -a

Linux localhost.localdomain 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

5. 下载


https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html


解压

mkdir -p /usr/local/java

tar zxvf  /var/local/jdk-8u211-linux-x64.tar.gz -C /usr/local/java

6. 配置环境变量


vim /etc/profile

注:如果修改当前用户的环境变量 编辑~/.profile或~/.bashrc文件即可,而不是/etc/profile。

在文件最后添加如下配置:

JAVA_HOME=/usr/local/java/jdk1.8.0_211

export CLASSPATH=$:CLASSPATH:$JAVA_HOME/lib/

export PATH=$PATH:$JAVA_HOME/bin

重新加载配置文件,使配置生效(su root):

source /etc/profile

source ~/.bash_profile

7. 检查是否安装成功


查看java安装脚本

java -version

显示:

java version "1.8.0_211"
Java(TM) SE Runtime Environment (build 1.8.0_211-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.211-b12, mixed mode)

查看执行参数

javac

Usage: javac <options> <source files>
where possible options include:
-g                         Generate all debugging info
-g:none                    Generate no debugging info
-g:{lines,vars,source}     Generate only some debugging info
-nowarn                    Generate no warnings
-verbose                   Output messages about what the compiler is doing
-deprecation               Output source locations where deprecated APIs are used
-classpath <path>          Specify where to find user class files and annotation processors
-cp <path>                 Specify where to find user class files and annotation processors
-sourcepath <path>         Specify where to find input source files
-bootclasspath <path>      Override location of bootstrap class files
-extdirs <dirs>            Override location of installed extensions
-endorseddirs <dirs>       Override location of endorsed standards path
-proc:{none,only}          Control whether annotation processing and/or compilation is done.
-processor <class1>[,<class2>,<class3>...] Names of the annotation processors to run; bypasses default discovery process
-processorpath <path>      Specify where to find annotation processors
-parameters                Generate metadata for reflection on method parameters
-d <directory>             Specify where to place generated class files
-s <directory>             Specify where to place generated source files
-h <directory>             Specify where to place generated native header files
-implicit:{none,class}     Specify whether or not to generate class files for implicitly referenced files
-encoding <encoding>       Specify character encoding used by source files
-source <release>          Provide source compatibility with specified release
-target <release>          Generate class files for specific VM version
-profile <profile>         Check that API used is available in the specified profile
-version                   Version information
-help                      Print a synopsis of standard options
-Akey[=value]              Options to pass to annotation processors
-X                         Print a synopsis of nonstandard options
-J<flag>                   Pass <flag> directly to the runtime system
-Werror                    Terminate compilation if warnings occur
@<filename>                Read options and filenames from file

出现以上信息则代表安装成功。

相关阅读 >>

CentOS7安装jdk8

更多相关阅读请进入《CentOS7》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...