[英]Installing Oracle jdk 11 on ubuntu 18.04 LTS
Recently oracle has changed their policy of license.最近 oracle 改变了他们的许可政策。 I couldn't install oracle jdk 11 on ubuntu 18.04 LTS.
我无法在 ubuntu 18.04 LTS 上安装 oracle jdk 11。 Can anyone please suggest any specific solution for that?
任何人都可以为此提出任何具体的解决方案吗? thank you
谢谢你
I created a gist to help me address this specific issue: https://gist.github.com/Thoughtscript/d5cdba8013a006dbbd2899e899b95146我创建了一个要点来帮助我解决这个特定问题: https://gist.github.com/Thoughtscript/d5cdba8013a006dbbd2899e899b95146
Partly reprised below.下面部分重演。 It took me a while but I got it to work with the OpenJDK-11.0.2 at the jdk.java.net link below.
我花了一段时间,但我在下面的 jdk.java.net 链接上让它与 OpenJDK-11.0.2 一起工作。
NOTE It's recommended to download Java 11+ directly from Oracle. It's further recommended to use the OpenJDK 11.0.2 (and avoid other options).
See: https://jdk.java.net/archive/
sudo apt-get update
wget "https://download.java.net/java/GA/jdk11/9/GPL/openjdk-11.0.2_linux-x64_bin.tar.gz"
sudo tar -xzvf openjdk-11.0.2_linux-x64_bin.tar.gz
sudo mv jdk-11.0.2 /usr/lib/jvm/
# Config
sudo nano /etc/environment
# Add the line below
# JAVA_HOME="/usr/lib/jvm/jdk-11.0.2/"
# Config
sudo nano ~/.bashrc
# Add the lines below
# JAVA_HOME=/usr/lib/jvm/jdk-11.0.2/
# PATH=$JAVA_HOME/bin:$PATH
source ~/.bashrc
# Verify
echo $JAVA_HOME
javac --version
I'm not sure which JDK you wanted, but here's a couple options:我不确定您想要哪个 JDK,但这里有几个选项:
If you want the closed-source JDK 11, go to the official site and download and install the.deb file .如果你想要闭源的JDK 11, go到官网下载安装.deb文件。
If you want OpenJDK 11, go to the official site and download the.tar.gz file .如果你想要 OpenJDK 11, go 到官网下载 .tar.gz 文件。 Then extract it to a location you want and set the environment variables .
然后将其解压缩到您想要的位置并设置环境变量。
.deb
package from Oracle site.deb
package install the package by double clicking on it.通过双击安装 package。
Once it is installed set the JAVA_HOME in environment安装后在环境中设置 JAVA_HOME
sudo nano /etc/environment
and add the line JAVA_HOME="/usr/lib/jvm/jdk-11.0.1/"
sudo nano /etc/environment
并添加行JAVA_HOME="/usr/lib/jvm/jdk-11.0.1/"
Add the configuration in .bashrc
在
.bashrc
中添加配置
sudo nano ~/.bashrc
and add following lines sudo nano ~/.bashrc
并添加以下行
JAVA_HOME=/usr/lib/jvm/jdk-11.0.11/
PATH=$JAVA_HOME/bin:$PATH
refresh the new configuration with source ~/.bashrc
使用
source ~/.bashrc
刷新新配置
enter he command java-version
and you can see the version installed输入命令
java-version
可以看到安装的版本
OR
Configurations in (step 3 - step 5 )also can be done by using below method as well (步骤 3 - 步骤 5)中的配置也可以使用以下方法完成
Run command运行命令
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-11.0.11/bin/java 2
sudo update-alternatives --config java
select the desired version from prompt if here are multiple java versions already installed and run following commands select 如果这里已经安装了多个 java 版本,则提示所需的版本并运行以下命令
sudo update-alternatives --install /usr/bin/jar jar /usr/lib/jvm/jdk-11.0.11/bin/jar 2
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk-11.0.11/bin/javac 2
sudo update-alternatives --set jar /usr/lib/jvm/jdk-11.0.11/bin/jar
sudo update-alternatives --set javac /usr/lib/jvm/jdk-11.0.11/bin/javac
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.