You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Ubuntu系统中安装JDK 10?Oracle官方指引缺少系统配置说明

Installing JDK 10 on Ubuntu (Full Step-by-Step Guide)

Hey there! I totally get it—Oracle's official docs for JDK 10 on Linux only cover downloading and extracting the archive, skipping the critical system configuration steps. Let me walk you through the complete process to get JDK 10 up and running properly on Ubuntu.

1. Download the JDK 10 Archive

Head over to Oracle's JDK archive (look for the Linux x64 .tar.gz package) and download it to your ~/Downloads directory (or wherever you prefer storing downloads).

2. Extract the Archive to a System Directory

Ubuntu typically stores Java installations in /usr/lib/jvm/, so we'll use that location:

  • First, create the directory if it doesn't exist:
    sudo mkdir -p /usr/lib/jvm/
    
  • Extract the downloaded archive to this directory (replace jdk-10*.tar.gz with your actual filename if needed):
    sudo tar -xvzf ~/Downloads/jdk-10*.tar.gz -C /usr/lib/jvm/
    
    Pro tip: Run ls /usr/lib/jvm/ afterward to get the exact name of the extracted JDK folder (it'll look like jdk-10.0.2 or similar—you'll need this for the next steps).

3. Configure Environment Variables (The Part Oracle Misses)

This step ensures your system recognizes JDK 10 globally. You have two options:

Option A: Global Configuration (All Users)

Edit the system-wide profile file:

sudo nano /etc/profile

Add these lines at the end of the file (replace jdk-10.x.x with your actual JDK folder name):

export JAVA_HOME=/usr/lib/jvm/jdk-10.x.x
export PATH=$PATH:$JAVA_HOME/bin

Save and exit (press Ctrl+O, then Enter, then Ctrl+X). To apply the changes immediately:

source /etc/profile

Option B: User-Only Configuration (Current User)

If you only want JDK 10 available for your user account, edit your bashrc file instead:

nano ~/.bashrc

Add the same two lines as above at the end, then apply changes:

source ~/.bashrc

4. Set JDK 10 as the Default Java Version

If you have other Java versions installed, set JDK 10 as the default:

  • Register JDK 10 with the alternatives system:
    sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-10.x.x/bin/java 100
    sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk-10.x.x/bin/javac 100
    
    The number 100 sets a high priority, so this version will be preferred over others.
  • Select the default Java and compiler versions:
    sudo update-alternatives --config java
    sudo update-alternatives --config javac
    
    When prompted, enter the number corresponding to JDK 10 and press Enter.

5. Verify the Installation

To make sure everything worked, run these commands:

java -version
javac -version

You should see output similar to this (version number may vary):

openjdk version "10.0.2" 2018-07-17
OpenJDK Runtime Environment 18.3 (build 10.0.2+13)
OpenJDK 64-Bit Server VM 18.3 (build 10.0.2+13, mixed mode)

That's it—you've successfully installed and configured JDK 10 on Ubuntu!

内容的提问来源于stack exchange,提问作者Sam

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 04:18:43