Installing Java on a dedicated server isn't quite the same as a desktop machine where visiting a URL, clicking and confirming, then voila you're done. Installing Java on a KnownHost dedicated server hosting account isn't a huge undertaking, but there is a bit more to it.
Before running through the steps to install, first make sure that:
Knowing how to install Java on a dedicated server is one thing. Knowing which flavor of Java to install on a dedicated server is another.
Java comes in 4 different platforms:
The most popular platform for this scenario is Java SE.
If you've decided on Java SE, it's now time to question whether you'll be doing development and programming tasks or if you'll just be wanting to execute Java apps.
For development and programming using Java, you'll be wanting the Java Development Kit. It's available free and open source as OpenJDK.
For cases where you just want to be able to run Java applications, but don't need a full-blown development environment, the choice is the Java Runtime Environment, available free and open source as OpenJRE.
You've decided on Java SE (OpenJDK), so now what? The next critical decision is in choosing what numerical version of Java (which version) you'd like to install.
If you've dealt with CMS systems, like WordPress, enough, you may be conditioned to installing the most recent version, so that you stay current and are protected against the latest exploits. Java is a bit different.
Java, and other enterprise software, operates with a product lifecycle management policy known as long-term support (LTS). With LTS, a particular version of the software is singled out to be actively maintained and supported for a much longer period of time.
The whole idea behind LTS is that companies can spend their time and money in developing based on a stable, relatively unchanging platform, that they can depend on for years to come.
Java 11 came out in September, 2018 and will be supported for roughly a decade!
If you're running a mission critical enterprise on Java applications, then the prudent course of action is to choose the current LTS version of Java, Java 11.
Let's move ahead with the plan being to install Java 11 OpenJDK in a KnownHost dedicated server running CentOS.
Installing OpenJDK 11 will, by nature of the install packages, also install the Java Runtime Environment (OpenJRE 11).
Step 1 - Make sure the package repository is fully updated
sudo yum update
Step 2 - Install OpenJDK (look for Complete! message at the end)
sudo yum install java-11-openjdk-devel
Step 3 - Confirm install was a success
If you've just installed OpenJDK 11, you might now have two different versions of Java available on the server. This is actually a good thing, for developers, since some dev work may want to be targeting an older version, like Java 8 (the previous LTS version of Java).
There can only be one default version at any particular point in time and you need to know what versions are available.
Execute the following to see what Java version alternatives are available to choose from on the server at present:
sudo alternatives --config java
Updating the default version can be done with:
sudo update-alternatives --config java
If you see two, three, four or more in the list, you'll be prompted to type the number representing which one in the list you'd like to set as the default version of Java on the machine. Pick the number and press [ENTER].