Java is a general-purpose programming language that can be used to develop a wide variety of applications. In order to start developing with Java or installing programs that require the Java Runtime Environment (JRE) to operate, you must first install Java and the Java Development Kit (JDK). As this process differs depending on your operating system, this article will focus on installing Java on Ubuntu via the command-line interface (CLI). For CentOS 7 users, please refer to this article.
Install Java on your Dedicated Hosting server and start developing today!
In order to run Java-based software on your machine, you must first install the Java Runtime Environment. Installing the JRE will require use of the standard Ubuntu commands apt and apt-get to download and install the necessary software packages.
- Before installing Java, you will first want to check to see if it is already installed. To do this, run the following command:
- If it is not already installed, you can install Java with the following command:
sudo apt-get install -y default-jre
- Once the installation has finished, you can verify the installation with the following command:
- If the installation was successful, the output should look something like this:
openjdk version "1.8.0_252"
OpenJDK Runtime Environment (build 1.8.0_252-8u252-b09-1~16.04-b09)
OpenJDK 64-Bit Server VM (build 25.252-b09, mixed mode)
Congratulations, you have now installed Java!
Installing the Java Development Kit (JDK)
If you are looking to use Java for development purposes, you will first need to install the Java Development Kit, which contains all of the necessary software required for developing Java-based applications.
- To install the JDK, use the following command:
sudo apt install default-jdk
- Once the installation has finished, you can verify that installation with the following command:
- If the installation was successful, the output should look as follows:
Congratulations, you are now prepared to start developing with Java on your Ubuntu machine!