This article will guide you through installing Java or the Java Runtime Environment (JRE) on a VPS or Dedicated server. We will provide step-by-step instructions on installing Java, including checking for existing installations, selecting the appropriate Java version, and downloading the installation package.
By the end of the article, you will have a clear understanding of how to install Java on your VPS or Dedicated server and ensure that your web server is equipped to handle Java-based applications effectively.
Check for Existing Installation
IMPORTANT: These solutions will require root access. If this needs to be obtained, follow the guide on requesting root access.
- Access your server via SSH as the root user or using the Terminal in Root WHM
- Ensure Java is not already installed by using
java -version
TIP: If installed, it will tell you the current version. If not installed, the output will show-bash: java: command not found
Install Java via OpenJDK
- Access your server via SSH as the root user or using the Terminal in Root WHM
- For OpenJDK, search the repository by using
yum search openjdk
- For AlmaLinux, install the latest version by running
yum install java-latest-openjdk-headless.x86_64
- For CentOS, the specific version needs to be used in the command, as the -latest- option isn't recognized
EXAMPLE:yum install java-11-openjdk-headless.x86_64
- For AlmaLinux, install the latest version by running
Install Oracle Java via RPM
- For Oracle Java, you will need to download the RPM file from Oracle's server, then install it onto your server
IMPORTANT: This is only recommended if you specifically need Oracle Java. You will need to update it on your own, as it will not receive automatic security updates like OpenJDK would through the system's repositories. By going to Oracle's site and getting the link, you are agreeing to their terms of service. This is why we cannot provide the file's link in this article for you.
- Open Oracle Java Downloads and right-click
- Copy the link address for the x64 RPM Package for your chosen version
- In your terminal, to download the package, you will use wget and then paste the link you copied
EXAMPLE:wget Your Link here
- You should see the progress of the download and a success message once it is complete
- Once it is downloaded, you will then install the RPM file by running
yum localinstall jdk-20_linux-x64_bin.rpm
REPLACE: jdk-20_linux-x64_bin.rpm with the name of the RPM you downloaded.
- You can confirm Java was installed by running
java -version
again
EXAMPLE:
root@vps [/]# java -version
openjdk version "20.0.1" 2023-04-18
OpenJDK Runtime Environment (Red_Hat-20.0.1.0.9-4.rolling.el8) (build 20.0.1+9)
OpenJDK 64-Bit Server VM (Red_Hat-20.0.1.0.9-4.rolling.el8) (build 20.0.1+9, mixed mode, sharing)
Comments
0 comments
Article is closed for comments.