如何在 Ubuntu Linux 上安装 JDK [英] How to install the JDK on Ubuntu Linux
问题描述
注意:这是一个古老的问题,答案反映了当时的世界.现代 Ubuntu 发行版有可用的 OpenJDK,可以安装
Note: This is an old question and the answers reflect the world as it was then. Modern Ubuntu distributions have OpenJDK available which can be installed with
sudo apt install default-jdk
我正在尝试在 Java 开发工具包 (JDK) 上安装 Ubuntu Linux 发行版,但我无法安装.
I am trying to install the Java Development Kit (JDK) on Ubuntu Linux distribution, but I am unable to install it.
在 Ubuntu 上安装它的步骤是什么?
What are the steps to install it on Ubuntu?
推荐答案
参考 Ask Ubuntu 问题 如何为 OpenJDK 设置 JAVA_HOME?,
如何在 Ubuntu (Linux) 中安装 Open JDK
(Java 开发工具包)?
How to install Open JDK
(Java developement kit) in Ubuntu (Linux)?
从 Application Dash 打开 Terminal 或按 Ctrl+Alt+T
更新仓库:
sudo add-apt-repository ppa:openjdk-r/ppa # only Ubuntu 17.4 and earlier
sudo apt update
可选:要搜索 openjdk
的可用发行版,请使用以下命令:
Optional: To search available distributions of openjdk
, use the following command:
apt search openjdk
使用以下命令安装适当的版本:
Install the appropriate version with the following command:
sudo apt install openjdk-8-jdk
sudo apt install openjdk-8-source #this is optional, the jdk source code
对于JAVA_HOME
(环境变量)类型的命令如下所示,在终端"中使用你的安装路径...
For JAVA_HOME
(Environment Variable) type command as shown below, in "Terminal" using your installation path...
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk
(注意:/usr/lib/jvm/java-8-openjdk
在这里象征性地使用只是为了演示.你应该根据你的安装使用你的路径.)
(Note: /usr/lib/jvm/java-8-openjdk
is symbolically used here just for demostration. You should use your path as per your installation.)
对于PATH
(环境变量)类型的命令如下所示,在Terminal
中:
For PATH
(Environment Variable) type command as shown below, in Terminal
:
导出路径=$PATH:$JAVA_HOME/bin
要检查您的安装:
java -version
这篇关于如何在 Ubuntu Linux 上安装 JDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!