All Products
Search
Document Center

Elastic Compute Service:Deploy OpenJDK

Last Updated:Jul 15, 2026

Install, upgrade, or replace OpenJDK on Linux and Windows ECS instances, including environment checks and version-specific setup.

Install OpenJDK

Note

Connect to the ECS instance on which you want to install OpenJDK.

Linux

Run java -version to check for an existing Java installation. If the installed version does not meet your requirements, uninstall it first.

Uninstall the Java environment

  • For RPM-based systems (Alibaba Cloud Linux, CentOS, Fedora):

    1. Query installed Java packages.

      sudo rpm -qa | grep java
    2. Remove each returned package. Replace <Package name> with the actual package name.

      sudo rpm -e --nodeps <Package name>
  • For DPKG-based systems (Ubuntu, Debian):

    1. Query installed Java packages.

      sudo dpkg --list | grep java
    2. Remove each returned package. Replace <Package name> with the actual package name.

      Note

      The --purge option removes both the packages and their configuration files.

      sudo apt-get remove --purge <Package name>
  1. Update the package manager.

    • DNF-based systems (Alibaba Cloud Linux 3, CentOS 8):

      sudo dnf update
    • YUM-based systems (Alibaba Cloud Linux 2, CentOS 7):

      sudo yum update
    • APT-based systems (Ubuntu, Debian):

      sudo apt update
  2. Search for available OpenJDK packages.

    • DNF-based systems (Alibaba Cloud Linux 3, CentOS 8):

      sudo dnf search openjdk
    • YUM-based systems (Alibaba Cloud Linux 2, CentOS 7):

      sudo yum search openjdk
    • APT-based systems (Ubuntu, Debian):

      sudo apt search openjdk
  3. Install OpenJDK. The following example uses Java 1.8. To install a different version, replace the package name with the one from the previous step.

    • DNF-based systems (Alibaba Cloud Linux 3, CentOS 8):

      sudo dnf install -y java-1.8.0-openjdk-devel
    • YUM-based systems (Alibaba Cloud Linux 2, CentOS 7):

      sudo yum install -y java-1.8.0-openjdk-devel
    • APT-based systems (Ubuntu, Debian):

      sudo apt-get install -y openjdk-8-jdk
  4. Verify the installation.

    Note

    Package manager installations automatically configure symbolic links, so no manual environment variable setup is needed.

    java -version

    If the installation is successful, output similar to the following is returned:

    [root@iZbp1jxxx java]# java -version
    openjdk version "1.8.0_432"
    OpenJDK Runtime Environment (build 1.8.0_432-b06)
    OpenJDK 64-Bit Server VM (build 25.432-b06, mixed mode)

Windows

Important

The following example uses Java 1.8. Your Windows instance must have Internet access to download the package.

Download the OpenJDK package

Download the package from the OpenJDK 8 official website.

Note

To install a different version, select Java SE <xx> in the left-side navigation pane. Replace <xx> with the target version. For example, select Java SE 21 to download OpenJDK 21.

In the RI Binaries section of the download page, click the Windows 11 i586 Java Development Kit link to download.

Install OpenJDK

Note

The following example uses C:/Program Files. Replace it with your preferred directory if needed.

  1. Place the downloaded OpenJDK package (e.g., openjdk-8u44-windows-i586.zip) in the C:\Program Files directory.

  2. Extract the package, open the extracted directory, and copy the absolute path from the address bar. The extracted OpenJDK directory path is C:\Program Files\openjdk-8u44-windows-i586\java-se-8u44-ri, containing folders such as bin, jre, and lib. Confirm this path as the JAVA_HOME variable value for subsequent steps.

  3. Configure environment variables.

    1. Right-click This PC and select Properties.

    2. On the About page, scroll down and click Advanced system settings.

    3. Click Environment Variables.

    4. In System variables, click New. Set Variable name to JAVA_HOME and Variable value to the OpenJDK installation path (e.g., C:\Program Files\openjdk-8u44-windows-i586\java-se-8u44-ri). Click OK.

    5. Select the Path variable in System variables and click Edit.

    6. Add these two paths:

      %JAVA_HOME%\bin
      %JAVA_HOME%\jre\bin
    7. Click OK twice to save the settings.

  4. Press Win+R, enter cmd, and verify the installation:

    java -version

    If the installation is successful, output similar to the following is returned:

    C:\Users\Administrator>java -version
    openjdk version "1.8.0_44"
    OpenJDK Runtime Environment (build 1.8.0_44-b02)
    OpenJDK Client VM (build 25.40-b25, mixed mode)