栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

Centos7离线安装JDK1.8【超详细】

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Centos7离线安装JDK1.8【超详细】

Centos7离线安装JDK1.8【超详细】 1、检查当前系统是否安装JDK
命令:java -version
注释:查看JDK安装版本,命令执行后显示如下,说明本系统已默认安装java version "1.8.0_231"

[root@tiepihetao /]# java -version
java version "1.8.0_231"
Java(TM) SE Runtime Environment (build 1.8.0_231-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.231-b11, mixed mode)

2、检测系统JDK默认安装包
命令:rpm -qa | grep java
注释:意思是搜索Java,查看安装包文件。

3、卸载JDK
命令:rpm -e –nodeps 名称
4、安装JDK

​ 到JDK官网上下载所需JDK版本,下载完成后将安装的JDK安装包上传到Linux系统指定的文件目录下,进入该文件目录下。

或者去JDK1.8下载,免积分。

4.1、创建JDK上传所需文件夹

注意:也可以存放到自己喜欢的目录下[此操作只是便于后期管理]

命令:mkdir /usr/local/src/java
注释:在/usr/local/src/目录下创建java目录

命令:cd /usr/local/src/java
注释:进入刚刚创建好的java目录

命令:pwd
注释:查看文件全路径

命令:ls
注释:查看文件是否上传成功

4.2、解压JDK文件
命令:tar -zxvf jdk-8u231-linux-x64.tar.gz
注释:解压JDK安装包

5、配置环境变量

注意:Linux环境变量配置都在:/etc/profile文件中

VI命令编辑文件[建议编辑前复制一份源文件作为备份]

命令:vi /etc/profile
………略………
如果要添加到结尾,用按键"Shift+g"定位到文件尾,点击'i' 进入编辑。

填入以下内容:

# 注意:JAVA_HOME后面修改为自己的完整路径
export JAVA_HOME=/usr/local/src/java/jdk-8u231
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

编辑完成后,点击’esc’按钮退出编辑模式
用命令’:wq!'保存退出

命令::wq!
注释:报存并退出

重点说明:

在Window系统中环境变量分隔符使用“分号”,在Linux系统中使用“冒号”。
在Linux系统中“变量名”标识取值的意思。
以上PATH变量的值除了设置了JAVA环境外,还取用了另一个PATH的值,这个被取用的PATH值,实际指向Linux命令集,如果没有该配置,Linux命令将无法使用(使用就显示未找到命令)!
6、重新加载系统配置文件

注意:重新加载系统配置文件,可以使配置在不用重启的情况下立即生效。

命令:source /etc/profile
注释:重新加载系统配置文件

7、检查JDK是否安装成功
命令:java -version
注释:查看JDK安装版本

[root@tiepihetao /]# Java
Usage: java [-options] class [args...]
           (to execute a class)
   or  java [-options] -jar jarfile [args...]
           (to execute a jar file)
....略....

[root@tiepihetao /]# javac
显示如下内容:
Usage: javac  
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           Specify where to find user class files and annotation processors
  -cp                  Specify where to find user class files and annotation processors
  -sourcepath          Specify where to find input source files
  -bootclasspath       Override location of bootstrap class files
  -extdirs             Override location of installed extensions
  -endorseddirs        Override location of endorsed standards path
  -proc:{none,only}          Control whether annotation processing and/or compilation is done.
  -processor [,,...] Names of the annotation processors to run; bypasses default discovery process
  -processorpath       Specify where to find annotation processors
  -parameters                Generate metadata for reflection on method parameters
  -d              Specify where to place generated class files
  -s              Specify where to place generated source files
  -h              Specify where to place generated native header files
  -implicit:{none,class}     Specify whether or not to generate class files for implicitly referenced files
  -encoding        Specify character encoding used by source files
  -source           Provide source compatibility with specified release
  -target           Generate class files for specific VM version
  -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                   Pass  directly to the runtime system
  -Werror                    Terminate compilation if warnings occur
  @                Read options and filenames from file

至此JDK8安装完成

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/941348.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号