Java is a powerful programming language, software written in Java can be compiled and run on any system. Unlike Python and C, Java is not pre-installed on Linode's distribution images. OpenJDK is a free and open source alternative to the Java SE Development Kit (JDK, Java Standard Edition Development Kit). This article describes how to install the OpenJDK 8 operating environment and development kit on CentOS 7.
Read the Getting Started Guide, and set the Linode hostname and time zone.
This article will try to use the sudo command as much as possible.
Update system:
sudo yum update
If you don't plan to use Java to write software, but just want to run programs written in Java, then we only need JRE. In CentOS, the JRE package name is java-$(version)-openjdk
. The openjdk-headless
package contains a minimal implementation for the JDK, allowing us to execute Java applications on the command line. Enter the following command to install the minimum version of OpenJDK 8
sudo yum install java-1.8.0-openjdk-headless
After the installation is complete, enter yum list installed | grep "java"
to see if the installation is successful. The output should be similar to:
java-1.8.0-openjdk-headless.x86_64 1:1.8.0.131-3.b12.el7_3 @updates
javapackages-tools.noarch 3.4.1-11.el7 @base
python-javapackages.noarch 3.4.1-11.el7 @base
tzdata-java.noarch 2017b-1.el7 @updates
If you plan to use Java to compile programs on Linode or other computers, you need to install JDK at this time.
sudo yum install java-1.8.0-openjdk-devel
After the installation is complete, enter yum list installed | grep "openjdk-devel"
to see if the installation is successful. The output should be similar to:
java-1.8.0-openjdk-devel.x86_64 1:1.8.0.131-3.b12.el7_3 @updates
You can also verify the success of the installation by running the Java compiler javac
. For example, if we want to compile a foobar.java
file, run javac foobar.java
to compile foobar.java
. Then, run java foobar
to execute the compiled foobar executable file.
For more information about this article, refer to the following resources.
Recommended Posts