Linux中安装JDK

 可以先在官网查看jdk安装说明

1、64位系统 https://docs.oracle.com/javase/8/docs/technotes/guides/install/linux_jdk.html#BJFJJEFGhttps://docs.oracle.com/javase/8/docs/technotes/guides/install/linux_jdk.html#BJFJJEFG

2、32位系统  

https://docs.oracle.com/javase/8/docs/technotes/guides/install/linux_jdk.html#BJFCDAIBhttps://docs.oracle.com/javase/8/docs/technotes/guides/install/linux_jdk.html#BJFCDAIB

安装说明以64位为例


Installation of the 64-bit JDK on Linux Platforms

This procedure installs the Java Development Kit (JDK) for 64-bit Linux, using an archive file (.tar.gz).

These instructions use the following files:

jdk-8uversion-linux-x64.tar.gz and jdk-8uversion-linux-aarch64.tar.gz (version 8u271 and later) for 64-bit ARM systems.

    Download the required file.

    Before the file can be downloaded, you must accept the license agreement. The archive file can be installed by anyone (not only root users), in any location that you can write to. However, only the root user can install the JDK into the system location.

    Change directory to the location where you would like the JDK to be installed, then move the .tar.gz archive file to the current directory.

    Unpack the archive file and install the JDK.
        For x64 - % tar zxvf jdk-8uversion-linux-x64.tar.gz
        For 64-bit ARM system - % tar zxvf jdk-8uversion-linux-aarch64.tar.gz

    The Java Development Kit files are installed in a directory called jdk1.8.0_version in the current directory.

    Delete the .tar.gz file if you want to save disk space.

中文解释:

 一、下载Linux版本的JDK

①我已经下载,放在CSDN资源 jdk-8u331-linux-x64.tar.gz-Java文档类资源-CSDN下载

②官网下载Linux版本的JDK

Java Downloads | Oracle

 

 会要求登录Oracle账号再开始下载

 二、在Linux中安装JDK

1、在Xshell中点击xftp

 2、找到下载下来的jdk···.tar.gz文件,双击该文件开始上传

 3、在XFTP左边所连接的Linux目录中,把上传的jdk···.tar.gz文件和Hadoop放在一个文件夹下

4、在xshell中解压jdk

①首先进入Opt目录

cd /home/bigdata/Opt

②再输入ll命令可以查看当前目录下的文件

③ 解压jdk···.tar.gz到当前文件夹中

tar -zxvf jdk-8u331-linux-x64.tar.gz

 ④查看解压结果

⑤在XFTP中查看解压后 jdk1.8.0_331 下的内容

 5、设置环境变量

①切换为root用户登录

su root

 

① 打开配置文件

vim /etc/profile

按提示输入 E

 ②输入配置信息

首先输入 i 进入 编辑模式 后如下图所示

 输入配置信息

#set java enviroment

export JAVA_HOME=/home/bigdata/Opt/jdk1.8.0_331
export JRE_HOME=/home/bigdata/Opt/jdk1.8.0_331/jre
export CLASS_PATH=.:$JAVA_HOME/lib:$JRE_HOME/lib
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin

 输入完成后,按 ESC键,退出编辑模式,再输入命令 :wq 保存配置文件,并退出编辑模式

③查看配置结果

可以再输入

vim /etc/profile

 然后在出现的提示中输入O

 查看确定后,可以Ctrl+Z 直接退出返回

输入 java -version 可以查看安装成功的JDK版本

java -version

------我瓶颈了,怎么是OpenJDK ,我不明白。这下又多点事来做,这个不行,要卸载,好在卸载简单。-------

卸载方法可以参考:

https://blog.csdn.net/c_lanxiaofang/article/details/124391159

卸载完OpenJDK后,

先执行source命令让之前配置过jdk环境的profile文件再次生效

source /etc/profile

 然后再查看jdk安装情况就出来了正常的Oracle的JDK了

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

懒笑翻

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值