Linux中安装JDK

Linux中安装JDK,第1张

 可以先在官网查看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了

 

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/739957.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-28
下一篇 2022-04-28

发表评论

登录后才能评论

评论列表(0条)

保存