All Products
Search
Document Center

Enterprise Distributed Application Service:Pin the JDK version for an ECS application

Last Updated:Mar 11, 2026

When an Enterprise Distributed Application Service (EDAS) application scales out, newly created Elastic Compute Service (ECS) instances may get a different Java Development Kit (JDK) version than existing ones. This mismatch causes runtime errors in your business code.

To prevent this, add a pre-launch mount script that pins a specific JDK version. Once configured, every instance -- existing or newly scaled out -- runs the same JDK.

Why JDK versions drift

EDAS installs the latest OpenJDK on each ECS instance imported into a cluster. Over time, the "latest" version changes. Instances created months ago still run the older JDK, while instances added during a scale-out get the current version.

A pre-launch mount script solves this by downloading and installing the exact JDK version you specify before the application starts. Because the script runs on every instance launch, all instances converge on the same version.

Note: Pinning to an exact version (for example, 8u202) means instances no longer receive automatic JDK updates. Plan periodic manual updates to apply security patches.

Pre-launch script

The following script checks whether the target JDK is already installed. If not, it downloads the package from an internal Object Storage Service (OSS) URL, extracts it, and sets file permissions.

JDK_DOWNLOAD_URL="http://doctest.oss-cn-hangzhou-internal.aliyuncs.com/tmp/oracle-jdk-8u202-linux-x64.tar.gz"
JDK_DOWNLOAD_TMP_FILE="/tmp/oracle-jdk-8u202.tar.gz"
JDK_HOME="/opt/edas/jdk"
JAVA_HOME="${JDK_HOME}/java"

if [ ! -f "${JAVA_HOME}/bin/java" ]; then
   rm -rf ${JAVA_HOME} && mkdir -p ${JDK_HOME}
   wget -q --dns-timeout=2 --connect-timeout=3 --read-timeout=30 ${JDK_DOWNLOAD_URL} -O ${JDK_DOWNLOAD_TMP_FILE}
   [ -f "${JDK_DOWNLOAD_TMP_FILE}" ] && tar zxf ${JDK_DOWNLOAD_TMP_FILE} -C ${JDK_HOME} && rm -f ${JDK_DOWNLOAD_TMP_FILE}
   [ -n "$(ls -ld ${JDK_HOME}/jdk* 2>/dev/null)" ] && mv ${JDK_HOME}/jdk* ${JAVA_HOME}
fi

chmod -R 755 ${JAVA_HOME}

Replace the JDK_DOWNLOAD_URL value with the internal OSS URL of your JDK package. The following sections explain how to prepare the URL and add the script to the EDAS console.

VariableDescription
JDK_DOWNLOAD_URLInternal OSS download URL for your JDK package
JDK_DOWNLOAD_TMP_FILETemporary local path for the downloaded archive
JDK_HOMEParent directory for the JDK installation (/opt/edas/jdk)
JAVA_HOMEFinal JDK path used by EDAS (/opt/edas/jdk/java)

Prerequisites

Before you begin, make sure you have:

  • An EDAS ECS application that you want to pin to a specific JDK version

  • The JDK package (for example, oracle-jdk-8u202-linux-x64.tar.gz) downloaded to your local machine

  • An OSS bucket in the same region as your ECS instances

Step 1: Upload the JDK package to OSS

  1. Upload the JDK package to an OSS bucket in the same region as your ECS instances. For more information, see Upload objects.

  2. Get the download URL of the uploaded package. For more information, see Share objects.

  3. Insert -internal into the URL hostname so that ECS instances download the package over the internal network. For example:

    http://doctest.oss-cn-hangzhou-internal.aliyuncs.com/tmp/oracle-jdk-8u202-linux-x64.tar.gz

    Using the internal endpoint avoids public bandwidth charges and is faster.

Step 2: Add the script to the EDAS console

  1. Log on to the EDAS console.

  2. In the left-side navigation pane, click Applications. In the top navigation bar, select the region. In the upper part of the Applications page, select the microservices namespace where your ECS application resides.

  3. Click the name of the target ECS application.

  4. On the Basic Information tab, in the Application Settings section, click Mount Script.

  5. In the Mount Script dialog box, go to the Pre-launch Script section:

    • Turn off Ignore failed so that the application does not start if the JDK installation fails.

    • Paste the script from the Pre-launch script section. Replace the JDK_DOWNLOAD_URL value with the internal OSS URL from Step 1.

  6. Click Modify.

Configure the pre-launch script

Step 3: Verify the JDK version

  1. Restart the ECS application to apply the mount script.

  2. After the application restarts, check the JDK version shown in the EDAS console.

    View the JDK version in the EDAS console

  3. (Optional) Log on to an ECS instance and run java -version to confirm the installed version matches the target version.

OpenJDK and alternative JDK vendors

  • OpenJDK with fontconfig: If you use a specific version of OpenJDK, add yum install -y fontconfig to the pre-launch script before the JDK installation commands. The fontconfig library is required for font rendering in certain Java applications.

  • JDK 11 or other vendors: To use JDK 11 or a JDK distribution from another vendor, configure the mount script to install the JDK to either /opt/edas/jdk/java or /opt/ali/alijdk.