Install Java on Centos 7

Select distribution:
Traducciones al Español
Estamos traduciendo nuestros guías y tutoriales al Español. Es posible que usted esté viendo una traducción generada automáticamente. Estamos trabajando con traductores profesionales para verificar las traducciones de nuestro sitio web. Este proyecto es un trabajo en curso.
Create a Linode account to try this guide with a $ credit.
This credit will be applied to any valid services used during your first  days.

Java is a powerful programming language. Software written in Java can compile and run on any system. Unlike Python or C, Java does not come pre-installed on Linode distribution images. This guide installs the OpenJDK 8 runtime environment and development kit in CentOS 7. OpenJDK is the free and open-source implementation of the Java SE Development Kit.

Before You Begin

  1. Familiarize yourself with our Getting Started guide and complete the steps for setting your Linode’s hostname and timezone.

  2. This guide will use sudo wherever possible.

  3. Update your system:

    sudo yum update
    

Install Java Runtime Environment (Java JRE)

If you don’t plan on using Java to write software, the JRE is all you need. In CentOS, the JRE package is java-$(version)-openjdk. The openjdk-headless package contains a minimal implementation of the JDK for executing Java applications on the command line. In this example, you’ll install the minimal version of OpenJDK 8.

sudo yum install java-1.8.0-openjdk-headless

After the installation finishes, verify its completion using yum list installed | grep "java". The output should be:

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

Install the Java Development Kit (Java JDK)

If you plan on using Java to write or edit programs on your Linode, install the JDK.

sudo yum install java-1.8.0-openjdk-devel

After the installation finishes, verify its completion using yum list installed | grep "openjdk-devel". The output should be:

java-1.8.0-openjdk-devel.x86_64      1:1.8.0.131-3.b12.el7_3           @updates

You can also verify by running the Java compiler, javac. If you need to compile Java code on your Linode, run javac foobar.java. Then, run the application with java foobar.

More Information

You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.

This page was originally published on


Your Feedback Is Important

Let us know if this guide was helpful to you.


Join the conversation.
Read other comments or post your own below. Comments must be respectful, constructive, and relevant to the topic of the guide. Do not post external links or advertisements. Before posting, consider if your comment would be better addressed by contacting our Support team or asking on our Community Site.
The Disqus commenting system for Linode Docs requires the acceptance of Functional Cookies, which allow us to analyze site usage so we can measure and improve performance. To view and create comments for this article, please update your Cookie Preferences on this website and refresh this web page. Please note: You must have JavaScript enabled in your browser.