系统相关
首页 > 系统相关> > ubuntu安装jdk

ubuntu安装jdk

作者:互联网

1. orcale官网下载jdk: https://www.oracle.com/java/technologies/downloads/#java11

jdk安装:
Compressed Archive 需自己编译
RPM Package :RPM包,redhat/suse等系统使用;
Debian Package 标准unix归档包,文件后缀deb;
deb是debian linux(ubuntu等)的安装格式;
rpm是redhat、fedora和suse的格式;

2.dpkg -i命令安装

dpkg -i jdk-11.0.16_linux-x64_bin.deb
root@ecs-df00:/home/dev# dpkg -i jdk-11.0.16_linux-x64_bin.deb 
Selecting previously unselected package jdk-11.
(Reading database ... 117282 files and directories currently installed.)
Preparing to unpack jdk-11.0.16_linux-x64_bin.deb ...
Unpacking jdk-11 (11.0.16-1) ...
Setting up jdk-11 (11.0.16-1) ...
root@ecs-df00:/home/dev# ll

查看安装结果

root@ecs-df00:/home/dev# find / -name jdk-11
/usr/lib/jvm/jdk-11
/usr/share/doc/jdk-11

3.设置环境变量:

在/etc/profile 或者 /etc/bash.bashrc(其他系统的/etc/.bashrc)中编辑添加:

#jdk
export JAVA_HOME=/usr/lib/jvm/jdk-11 export JRE_HOME=${JAVA_HOME} export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib export PATH=${PATH}:${JAVA_HOME}/bin

wq!保存退出并运行生效:

source /etc/profile

检查是否安装成功

root@ecs-df00:/usr/lib/jvm# echo $JAVA_HOME
/usr/lib/jvm/jdk-11
root@ecs-df00:/usr/lib/jvm# java -version
java version "11.0.16" 2022-07-19 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.16+11-LTS-199)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.16+11-LTS-199, mixed mode)

 

标签:11,lib,jdk,16,11.0,ubuntu,HOME,安装
来源: https://www.cnblogs.com/chencoolandclear/p/16530870.html