Liberica JDK 21.0.4+9: Installation Guide

1. Introduction

This guide describes how to install the Liberica product on Microsoft Windows, Linux, and macOS computers. The type of installation you choose depends on your requirements and the platform you use.

There are several Liberica distribution variants:

  • JDK Standard — use it to run, compile, and debug applications or create your own Java Runtime with a subset of Java modules;

  • JDK Full — includes LibericaFX and an extended set of VMs;

  • JDK Lite — install it if you are looking for a smaller footprint, yet fully functional JDK;

  • JRE Standard — use it to run Java applications;

  • JRE Full — includes LibericaFX and an extended set of VMs.

You can download Liberica from either the Liberica JDK Download Center or, as a support-plan customer, via a link on the support portal. After you log in to the support portal, you can see a direct link to the version of Liberica product you requested under Technologies. If you use the Liberica Download Center page, scroll down and select the OS, package type, and the distribution variant (JDK/JRE). After the download is completed, you can verify the downloaded file by comparing its size on your drive to the size on the Downloads page.

You can also use the command line to download the necessary installation packages as described further in this document.

Choose the OS below for specific installation instructions. Note that Liberica JDK is used for all examples below, but you can substitute it with Liberica JRE if necessary.

Note:
The installer screens are provided for information purpose only and may vary in different releases.

2. Microsoft Windows

Installing Liberica JDK using .msi file

  1. Double click the Windows installation file you downloaded to run the installer. This opens the Liberica JDK Setup Wizard.

  2. Click 'Next' on the Welcome screen.

  3. On the Custom Setup window, choose features you need. Select a feature to see its description. In most cases, you can use the default setup. Click Disk Usage to see the available and required space on your disk. Click 'Next'.

  4. The package is ready to install, press 'Install'. If you see the User Account Control warning, verify the publisher (BELLSOFT) and click Yes.

  5. After the installation is complete, click 'Finish' to quit the Liberica JDK Setup Wizard.

Silent installation using .msi file

If you want to install Liberica JDK silently without any user interaction, open the command line and run the following command:

msiexec /i bellsoft-jdk21.0.4+9-windows-amd64.msi /qn /quiet /norestart /l*v "Liberica_install.log"

Where

  • /i - install the specified software;

  • /qn - no UI;

  • /quiet - quiet mode without any user interaction;

  • /norestart - does not restart the computer after the installation is complete;

  • /l*v "Liberica_install.log" - verbose logging of all messages to the specified log file.

For the list of installation flags and options, run msiexec /help from the command line.

Note:
Use administrator account to run the installation in silent mode.

Installing a standalone package from an archive

  1. To install Liberica JDK as a standalone package on your computer, download the .zip package file and unpack it to a folder. You can also use Windows PowerShell to download and unpack the zip file as follows:

    Invoke-WebRequest "https://download.bell-sw.com/java/21.0.4+9/bellsoft-jdk21.0.4+9-windows-amd64.zip"
    Expand-Archive bellsoft-jdk21.0.4+9-windows-amd64.zip -DestinationPath .

    The commands above download the archive from the BELLSOFT public domain and unpack Liberica JDK to the current directory. If you are a support-plan customer, log in to the support portal, copy the link to the Liberica product under Technologies and paste this link to the Invoke-WebRequest command above.

  2. Add <Liberica JDK installation dir>/bin subdirectory to the PATH and <Liberica JDK installation dir> to the JAVA_HOME environment variables as follows.

    1. On the desktop or in File Explorer, right-click the Computer icon (This PC) and choose Properties on the context menu.

    2. Click Advanced system settings.

    3. Click Environment Variables.

    4. Select 'Path' in System variables and click Edit.

    5. Click New and type the path to the /bin subdirectory, for example:

      C:/LibericaJDK-21/bin/

      Click OK when finished.

    6. Select 'JAVA_HOME' in System variables and click Edit.

    7. Delete the variable’s current value and type the path to the <Liberica JDK installation dir> subdirectory.

      Note:
      If you do not have the JAVA_HOME variable, click New under System variables and type JAVA_HOME in Variable name and type the path in Variable value.
    8. Click OK in open dialog boxes to save the changes and reopen Command prompt window for the changes to take effect.

To run your application, use the following command:

java -jar <your_application.jar>

Verifying your installation

To verify your installation, open a command-line interface, such as PowerShell or cmd, and run the following command:

java -version

You should see an output similar to the following:

openjdk version "21.0.4" 2024-07-16 LTS
OpenJDK Runtime Environment (build 21.0.4+9-LTS)
OpenJDK 64-Bit Server VM (build 21.0.4+9-LTS, mixed mode, sharing)

Uninstalling Liberica JDK

Windows installer

If you installed Liberica JDK using Windows installation file (.msi), use the following procedure:

  1. From the Windows Control Panel, open Programs > Programs and Features and select Liberica package you want to remove.

  2. Click Uninstall.

Standalone package

To uninstall a standalone Liberica JDK package, remove its directory and related environmental variables in the Environment Variables dialog box.

3. Apple macOS

Installing Liberica JDK

To install Liberica JDK, perform the following:

  1. Run the installer by double-clicking the .dmg file you downloaded.

  2. Double-click the Install Liberica JDK 21.0.4+9.pkg icon to run the installation wizard.

  3. Click Continue on the Welcome screen.

  4. Click 'Install' to proceed with the default location.

    Optionally, you can change the installation location by clicking 'Change Install Location' on the Installation Type screen and selecting the location to install Liberica JDK.

    If you chose to change the installation location, select the destination drive and click 'Continue'.

  5. Confirm new software installation. The file copying starts immediately.

  6. Observe the installation progress.

  7. Once the installation is complete, click 'Close' to quit the installation wizard.

Installing a standalone package from an archive

To install Liberica JDK as a standalone package, download the .zip file and unpack it as in the following example.

wget https://download.bell-sw.com/java/21.0.4+9/bellsoft-jdk21.0.4+9-macos-amd64.zip
unzip bellsoft-jdk21.0.4+9-macos-amd64.zip

The commands above download the archive from the BELLSOFT public domain and unpack Liberica JDK to the current directory. If you are a support-plan customer, log in to the support portal, copy the link to the Liberica product under Technologies and paste this link to the wget command above.

Include the path to the <Liberica installation dir>/bin subdirectory when running your Java application as in the following example:

/Library/Java/JavaVirtualMachines/liberica-jdk-21.jdk/bin/java -jar <your_application.jar>

You can add the <Liberica installation dir>/bin subdirectory to the $PATH and <Liberica installation dir> to the JAVA_HOME environment variables for the current terminal session if necessary

export PATH=<Liberica installation dir>/bin:$PATH
export JAVA_HOME=<Liberica installation dir>

and run Liberica JDK as follows.

java -jar <your_application.jar>

Verifying your installation

To verify your installation, open the terminal and run the following command:

java -version

You should see an output similar to the following:

openjdk version "21.0.4" 2024-07-16 LTS
OpenJDK Runtime Environment (build 21.0.4+9-LTS)
OpenJDK 64-Bit Server VM (build 21.0.4+9-LTS, mixed mode, sharing)

Uninstalling Liberica JDK

Package installer

To uninstall Liberica JDK using the package installer, perform the following:

  1. Run the installer by double-clicking the .dmg file you downloaded.

  2. Double-click the Uninstall Liberica icon.

  3. Click 'Continue' on the Welcome screen.

  4. Select the Liberica installation you want to remove and click Continue.

  5. Provide authentication information if necessary and click OK. Once the uninstallation is completed, click Exit to quit the wizard.

Command line

To uninstall Liberica application using the Terminal, do the following (assuming that you installed Liberica using the default location on the boot volume (/)).

  • To uninstall Liberica JRE, run the following commands in the terminal:

    sudo pkgutil --volume / --forget com.bell-sw.liberica.jre21
    sudo rm -rf /Library/Java/JavaVirtualMachines/liberica-jre-21.jre
  • To uninstall Liberica JDK, run the following commands in the terminal:

    sudo pkgutil --volume / --forget com.bell-sw.liberica.jdk21
    sudo rm -rf /Library/Java/JavaVirtualMachines/liberica-jdk-21.jdk
Note:
For Liberica JDK lite or full versions add -lite or -full respectively to the name, such as liberica-jdk-21-full.jdk.

Standalone package

To uninstall a standalone Liberica JDK package, remove its directory. Related environment variables set with the export command are only valid for the current terminal session and they are removed once you close the terminal.

4. Linux

On most Linux versions, you can install new software using a repository, which is a storage location hosted on remote servers from which the system retrieves and installs software and updates. If the repository is not available or due to some other considerations, you can download and install new software manually.

Installing from repository

Alpine Linux Repository

To install Liberica JDK, perform the following.

  1. Setup the repository.

    echo "https://apk.bell-sw.com/main" | sudo tee -a /etc/apk/repositories
    sudo wget -P /etc/apk/keys/ https://apk.bell-sw.com/[email protected]
    Note:
    sudo command may require entering administrator password.
  2. Install packages.

    apk add bellsoft-java21

The following packages are available:

  • bellsoft-java21 contains the optimal build for most desktops/servers;

  • bellsoft-java21-lite includes Liberica JDK with compressed modules and Server VM, without any extra packages;

  • bellsoft-java21-runtime includes Liberica JRE only.

APT Repository (.deb-based Linux distributions)

To install Liberica JDK, perform the following.

  1. Add BELLSOFT official GPG key and set up the repository. Adding the GPG key is required only once on a computer.

    If you are running an Ubuntu prior to version 20, use the following command:

    wget -q -O - https://download.bell-sw.com/pki/GPG-KEY-bellsoft | sudo apt-key add -
    echo "deb https://apt.bell-sw.com/ stable main" | sudo tee /etc/apt/sources.list.d/bellsoft.list

    If you are running an Ubuntu version 20 or later, perform the following:

    1. For versions prior to Ubuntu 22.04, first create a directory.

      mkdir -m 0755 -p /etc/apt/keyrings/
    2. Add the key.

      wget -q -O - https://download.bell-sw.com/pki/GPG-KEY-bellsoft | gpg --dearmor | tee /etc/apt/keyrings/GPG-KEY-bellsoft.gpg > /dev/null
      "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/GPG-KEY-bellsoft.gpg] https://apt.bell-sw.com/ stable main" | sudo tee /etc/apt/sources.list.d/bellsoft.list

    Liberica JDK repositories contain all Linux architectures supported in the release: amd64, i386, arm64, armhf, ppc64le.

  2. Update repositories and install packages. Type Y if a warning message about the installed packages appears.

    sudo apt-get update
    sudo apt-get install bellsoft-java21

The following packages are available:

  • bellsoft-java21 contains the full Liberica JDK, including LibericaFX and a variety of JVMs for platforms which support it;

  • bellsoft-java21-lite includes Liberica JDK with compressed modules and Server VM, without any extra packages;

  • bellsoft-java21-full contains the full Liberica JDK, including LibericaFX and a variety of JVMs for platforms which support it;

  • bellsoft-java21-runtime includes Liberica JRE only;

  • bellsoft-java21-runtime-full contains the full Liberica JRE, including LibericaFX.

YUM Repository (.rpm-based Linux Distributions)

To install Liberica JDK, perform the following.

  1. Set up the repository.

    echo | sudo tee /etc/yum.repos.d/bellsoft.repo > /dev/null << EOF
    [BELLSOFT]
    name=BELLSOFT Repository
    baseurl=https://yum.bell-sw.com
    enabled=1
    gpgcheck=1
    gpgkey=https://download.bell-sw.com/pki/GPG-KEY-bellsoft
    priority=1
    EOF

    Liberica JDK repositories contain all Linux architectures supported in the release.

  2. Install packages.

    sudo yum install bellsoft-java21

The following packages are available:

  • bellsoft-java21 contains contains the the optimal build for most desktops/servers;

  • bellsoft-java21-lite includes Liberica JDK with compressed modules and Server VM, without any extra packages;

  • bellsoft-java21-full contains the full Liberica JDK, including LibericaFX and a variety of JVMs for platforms which support it;

  • bellsoft-java21-runtime includes Liberica JRE only;

  • bellsoft-java21-runtime-full contains the full Liberica JRE, including LibericaFX.

YaST/Zypper Repository (SUSE Linux)

To install Liberica JDK, perform the following.

  1. Set up the repository.

    echo | sudo tee /etc/zypp/repos.d/repo-bellsoft.repo > /dev/null << EOF
    [BELLSOFT]
    name=BELLSOFT Repository
    baseurl=https://yum.bell-sw.com
    enabled=1
    gpgcheck=1
    gpgkey=https://download.bell-sw.com/pki/GPG-KEY-bellsoft
    priority=1
    EOF
  2. Update repositories and install packages.

    sudo zypper up
    sudo zypper in bellsoft-java21

The following packages are available:

  • bellsoft-java21 contains the the optimal build for most desktops/servers;

  • bellsoft-java21-lite includes Liberica JDK with compressed modules and Server VM, without any extra packages;

  • bellsoft-java21-full contains the full Liberica JDK, including LibericaFX and a variety of JVMs for platforms which support it;

  • bellsoft-java21-runtime includes Liberica JRE only;

  • bellsoft-java21-runtime-full contains the full Liberica JRE, including LibericaFX.

Manual installation

Alpine Linux

  1. Download the .apk package with the following command in the terminal.

    wget https://download.bell-sw.com/java/21.0.4+9/bellsoft-jdk21.0.4+9-linux-x64-musl.apk

    Or open the downloads page in the browser, scroll down, and download the required package.

  2. Install the BELLSOFT official key as in the following example.

    sudo wget -P /etc/apk/keys/ https://apk.bell-sw.com/[email protected]
  3. Install this package with the following command.

    apk add bellsoft-jdk21.0.4+9-linux-x64-musl.apk

Ubuntu and other DEB-based OS’s

  1. To install Liberica JDK, download the .deb package using the 'wget' command in the command-line interface.

    wget https://download.bell-sw.com/java/21.0.4+9/bellsoft-jdk21.0.4+9-linux-amd64.deb

    Or open the downloads page in the browser, scroll down, and download the required package.

  2. Run the 'apt' tool as follows.

    sudo apt install ./bellsoft-jdk21.0.4+9-linux-amd64.deb

To use Liberica JDK, run the following command.

java -jar <your_application.jar>

Red Hat Linux and other RPM-based OS’s

To install Liberica JDK, download the .rpm package and run the rpm tool as in the following example.

wget https://download.bell-sw.com/java/21.0.4+9/bellsoft-jdk21.0.4+9-linux-amd64.rpm
sudo yum install ./bellsoft-jdk21.0.4+9-linux-amd64.rpm

The commands above install Liberica JDK 21 package.

To use Liberica JDK, run the following command.

java -jar <your_application.jar>

Manual RPM installation

  1. Obtain BELLSOFT official GPG key and then import it as in the following example. Adding the GPG key is required only once on a computer.

    wget https://download.bell-sw.com/pki/GPG-KEY-bellsoft
    sudo rpm --import ./GPG-KEY-bellsoft
  2. Download a package using the 'wget' command and install it as follows in the terminal.

    wget https://download.bell-sw.com/java/21.0.4+9/bellsoft-jdk21.0.4+9-linux-amd64.rpm
    sudo rpm --install bellsoft-jdk21.0.4+9-linux-amd64.rpm

Installing a standalone JDK package on GNU/Linux from archive

To install Liberica JDK, download the .tar.gz package and unpack it as follows.

wget https://download.bell-sw.com/java/21.0.4+9/bellsoft-jdk21.0.4+9-linux-amd64.tar.gz
tar -zxf bellsoft-jdk21.0.4+9-linux-amd64.tar.gz

The commands above unpack Liberica JDK to the current directory. To run your Java application, use the following command:

<Liberica installation dir>/bin/java -jar <your_application.jar>

You can add the <Liberica installation dir>/bin subdirectory to $PATH and <Liberica installation dir> to JAVA_HOME for the current terminal session if necessary.

export PATH=<Liberica installation dir>/bin:$PATH
export JAVA_HOME=<Liberica installation dir>

After that run your Java application as follows.

java -jar <your_application.jar>

Verifying your installation

To verify your installation, open a command-line interface and run the following command.

java -version

You should see an output similar to the following:

openjdk version "21.0.4" 2024-07-16 LTS
OpenJDK Runtime Environment (build 21.0.4+9-LTS)
OpenJDK 64-Bit Server VM (build 21.0.4+9-LTS, mixed mode, sharing)

Uninstalling Liberica JDK

Alpine Linux

Run the following command.

sudo apk del <bellsoft-package-name>

Ubuntu and other DEB-based OS’s

Run the following command.

sudo apt remove <bellsoft-package-name>

Red Hat Linux and other RPM-based OS’s

Run the following command.

sudo yum remove <bellsoft-package-name>

Removing manually installed standalone packages

To uninstall a standalone Liberica JDK package, remove its directory. Related environment variables are only valid for the current terminal session and they are removed once you close the terminal.

5. Verifying downloaded files

It is a good practice to verify the downloaded installation file by comparing its size on your drive to the size on the Downloads page.

A more advanced approach is to obtain the checksum of the downloaded file in a command-line interface and compare it to the one you can find next to the Liberica JDK link on the Downloads page. Check the OS-specific commands below.

Windows

To get the checksum of the downloaded file in the command-line, run the following command in Windows PowerShell. To run PowerShell, open the Start menu or press the Windows key + R, type powershell in the Run dialog box, and click OK.

(Get-FileHash .\bellsoft-jdk21.0.4+9-windows-amd64.msi -Algorithm SHA1).Hash

Apple macOS

To get the checksum of the downloaded file, use the following command.

shasum -a 1 bellsoft-jdk21.0.4+9-macos-amd64.dmg

Linux

To get the checksum of the downloaded file, use the following command. The installation file extension depends on the Linux version.

shasum -a 1 bellsoft-jdk21.0.4+9-linux-amd64.apk

6. Troubleshooting

This segment provides instructions to resolve some of the most common installation issues.

Checking system requirements

The JDK code can run on a number of platforms, using different compilers and build tools. We recommend checking your system compatibility and requirements on the Supported System Configurations page before installing Liberica product.

Microsoft Defender SmartScreen warnings

To ensure the security of the user’s computer, Microsoft Defender SmartScreen sometimes prevents running the downloaded files and triggers warnings while installing software.

If Microsoft Defender SmartScreen prevents installing the Liberica product and shows a message similar to the one below, follow the instructions in this section.

  1. Verify the downloaded Liberica installation file as described in Verifying downloaded files.

  2. Ensure that the installation file is signed by BELLSOFT by checking the details of the Digital Signatures in the Liberica installation file Properties.

  3. Depending on the verification results, do the following:

    • If the size and checksum of the downloaded file matches those on the Downloads page and the file is signed by BELLSOFT, click More info on the Microsoft Defender SmartScreen window and then click Run anyway.

    • If any of the verified information is not correct, delete the file and download the Liberica installation file again.

Browser warnings

If your browser prevents saving the downloaded Liberica installation file, click the Downloads icon and either click Keep or click More actions next to the downloaded file and, depending on the browser, select Keep or Download to save the file.

Silent installation on Windows

If after running a silent installation the software is not installed, check your log file for error messages. If the issue is the lack of administrator rights of the account running the installation, the log should contain a message similar to the following:

Error 1925. You do not have sufficient privileges to complete this installation for all users of the machine. Log on as administrator and then retry this installation.

Make sure you use administrator account for running silent installation.

Reverting to a previous Liberica product version on Windows

Important:
We do not recommend installing previous versions of Liberica products, because they may contain security issues resolved in the latest release.

If you have the latest version of a Liberica product installed and need to install some previous version of exactly the same product, first uninstall the current version and after that, install the version you need.

ON THIS PAGE