In this tutorial we will show you how to install and configuration of java JRE or JDK on your Ubuntu 16.04 server. Many programs and scripts that require java to run it, but usually Java is not installed by default on VPS or Dedicated Server. This article assumes you have at least basic knowledge of linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo’ to the commands to get root privileges. I will show you through the step by step installation JRE (Java Runtime Environment) and JDK (Java Development Kit) on Ubuntu 16.04.
Install Java (JRE or JDK) on Ubuntu 16.04
Step 1. First make sure that all your system packages are up-to-date by running these following apt-get commands in the terminal.
After your server has been fully updated, verify if java is installed or not:
If there is no java package installed ye, output will be something like:
Step 2. Installing Java (JRE or JDK).
Once you have verified if Java is installed or not, choose the type of Java installation that you want with one the following:
Another alternative Java install is with Oracle JRE and JDK. However, we would need to install additional repositories for a proper installation:
Then, you will need to fully update the system with the following command and install it:
Step 3. Verify Installed Java Version.
Step 4. Setup JAVA_HOME on Ubuntu 16.04.
Since many programs now days need a JAVA_HOME environment variable to work properly. We will need to find the appropriate path to make these changes. With the following command, you can view your installs and their path:
Now that you are in the user profile file, add the following code, along with the Path of your installation from the previous step, to the bottom. ( Example: JAVA_HOME=”YOUR_PATH”):
Reload the file so all your changes could take effect with the following command:
Verify that your implementations are correct with the following command:
Congratulation’s! You have successfully installed Java. Thanks for using this tutorial for installing Oracle Java (JRE or JDK) on Ubuntu 16.04 Xenial Xerus system. For additional help or useful information, we recommend you to check the official Java web site.