本文将介绍在Ubuntu 18.04/Ubuntu 16.04/Debian 9系统上安装Java 11的方法,可以通过openjdk-11.0.1_linux-x64_bin.tar.gz、jdk-11.0.1_linux-x64_bin.deb安装Java 11。由于Java SE Development Kit的许可证问题,建议安装OpenJDK 11。
在Ubuntu 18.04/16.04/Debian 9系统上安装OpenJDK 11(openjdk-11.0.1_linux-x64_bin.tar.gz) OpenJDK是根据GNU通用公共许可证版本2获得许可的Java平台标准版的免费开源版本。 在运行以下命令之前,请检查最新版本的OpenJDK 11(下载地址:https://ywnz.com/linuxrj/3150.html): curl -O https://download.java.net/java/GA/jdk11/13/GPL/openjdk-11.0.1_linux-x64_bin.tar.gz 将把OpenJDK 11 tar文件下载到你的工作目录。下载后,提取解压: tar zxvf openjdk-11.0.1_linux-x64_bin.tar.gz 将生成的文件夹移动到/usr/local/: sudo mv jdk-11* /usr/local/ 设置环境变量: sudo vim /etc/profile.d/jdk.sh 加入以下代码: export JAVA_HOME=/usr/local/jdk-11.0.1 export PATH=$PATH:$JAVA_HOME/bin 检查其java相关命令: $ source /etc/profile $ java -version openjdk version "11.0.1" 2018-10-16 OpenJDK Runtime Environment 18.9 (build 11.0.1+13) OpenJDK 64-Bit Server VM 18.9 (build 11.0.1+13, mixed mode) $ which java /usr/local/jdk-11.0.1/bin/java
在Ubuntu 18.04/16.04/Debian 9系统上安装Java SE Development Kit 11/JDK 11(jdk-11.0.1_linux-x64_bin.deb) 下载最新版本的JDK 11(下载地址:https://ywnz.com/linuxrj/3150.html): curl -LO -H "Cookie: oraclelicense=accept-securebackup-cookie" \ "http://download.oracle.com/otn-pub/java/jdk/11.0.1+13/90cf5d8f270a4347a95050320eef3fb7/jdk-11.0.1_linux-x64_bin.deb" 然后使用dpkg命令安装软件包: sudo dpkg -i jdk-11.0.1_linux-x64_bin.deb 如果遇到依赖性问题,请运行: $ sudo apt -f install $ sudo dpkg -i jdk-11.0.1_linux-x64_bin.deb Reading database ... 105838 files and directories currently installed.) Preparing to unpack jdk-11.0.1_linux-x64_bin.deb ... Unpacking jdk-11.0.1 (11.0.1-1) over (11.0.1-1) ... Setting up jdk-11.0.1 (11.0.1-1) ... 设置环境变量: sudo vim /etc/profile.d/jdk.sh 加入以下代码: export JAVA_HOME=/usr/lib/jvm/jdk-11.0.1/ export PATH=$PATH:$JAVA_HOME/bin 获取文件并确认已安装Java版本 $ source /etc/profile.d/jdk.sh $ java -version java version "11.0.1" 2018-10-16 LTS Java(TM) SE Runtime Environment 18.9 (build 11.0.1+13-LTS) Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.1+13-LTS, mixed mode
相关主题 |