Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
269 views
in Technique[技术] by (71.8m points)

java - 如何在Ubuntu Linux上安装JDK(How to install the JDK on Ubuntu Linux)

I am trying to install the Java Development Kit (JDK) on Ubuntu Linux distribution, but I am unable to install it.

(我正在尝试在Ubuntu Linux发行版上安装Java开发工具包 (JDK),但是无法安装它。)

What are the steps to install it on Ubuntu?

(在Ubuntu上安装它的步骤是什么?)

  ask by user2057084 translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Referring to Ask Ubuntu question How to set JAVA_HOME for OpenJDK?

(请参阅询问Ubuntu问题如何为OpenJDK设置JAVA_HOME?)

,

(,)

How to install Open JDK (Java developement kit) in Ubuntu (Linux)?

(如何在Ubuntu(Linux)中安装Open JDK (Java开发工具)?)

  1. Open Terminal from Application Dash or press Ctrl + Alt + T

    (从Application Dash打开终端或按Ctrl + Alt + T)

  2. Update repository:

    (更新存储库:)

     sudo add-apt-repository ppa:openjdk-r/ppa # only Ubuntu 17.4 and earlier sudo apt update 
  3. Optional: To search available distributions of openjdk , use the following command:

    (可选:要搜索openjdk可用发行版,请使用以下命令:)

     apt search openjdk 
  4. 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 
  5. For JAVA_HOME (Environment Variable) type command as shown below, in "Terminal" using your installation path...

    (对于JAVA_HOME (环境变量),请使用安装路径在“终端”中键入如下所示的命令...)

     export JAVA_HOME=/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.)

    ((注意: /usr/lib/jvm/java-8-openjdk在这里只是象征性地用于演示。您应该在安装时使用路径。))

  6. For PATH (Environment Variable) type command as shown below, in Terminal :

    (对于PATH (环境变量),在Terminal输入如下所示的命令:)

    export PATH=$PATH:$JAVA_HOME/bin

  7. To check your installation:

    (要检查您的安装:)

    java -version


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...