{"id":4620,"date":"2023-07-22T11:15:26","date_gmt":"2023-07-22T11:15:26","guid":{"rendered":"https:\/\/arzhost.com\/blogs\/?p=4620"},"modified":"2023-10-04T14:38:11","modified_gmt":"2023-10-04T14:38:11","slug":"install-java-11-12-on-centos-7","status":"publish","type":"post","link":"https:\/\/arzhost.com\/blogs\/install-java-11-12-on-centos-7\/","title":{"rendered":"How to Install Java 11 &#038; 12 on CentOS 7?"},"content":{"rendered":"<p>How to Install Java 11 &amp; 12 on CentOS 7? <a href=\"https:\/\/arzhost.com\/blogs\/how-to-install-java-on-raspberry-pi\/\">Java<\/a> is a very well-liked programming language that is used to create both desktop and lightweight mobile applications.<\/p>\n<p>This detailed tutorial will demonstrate how to set up Java on <a href=\"https:\/\/en.wikipedia.org\/wiki\/CentOS\" target=\"_blank\" rel=\"noopener\">CentOS 7<\/a>.<\/p>\n<ol>\n<li>A user account with sudo privileges<\/li>\n<li>Access to the command line\/terminal window<\/li>\n<li>The yum package manager, included by default<\/li>\n<\/ol>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_74 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/arzhost.com\/blogs\/install-java-11-12-on-centos-7\/#Versions_of_Java\" >Versions of Java<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/arzhost.com\/blogs\/install-java-11-12-on-centos-7\/#CentOS_Java_Installation\" >CentOS Java Installation<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/arzhost.com\/blogs\/install-java-11-12-on-centos-7\/#1_Activate_Openjdk_11\" >1: Activate Openjdk 11<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/arzhost.com\/blogs\/install-java-11-12-on-centos-7\/#2_Activate_OpenJRE_11\" >2: Activate OpenJRE 11<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/arzhost.com\/blogs\/install-java-11-12-on-centos-7\/#3_Oracle_Java_11_installation\" >3: Oracle Java 11 installation<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/arzhost.com\/blogs\/install-java-11-12-on-centos-7\/#Make_sure_Java_is_set_up_on_your_computer\" >Make sure Java is set up on your computer<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/arzhost.com\/blogs\/install-java-11-12-on-centos-7\/#Install_a_specific_Java_version\" >Install a specific Java version<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/arzhost.com\/blogs\/install-java-11-12-on-centos-7\/#Establishing_the_Default_Java_Version\" >Establishing the Default Java Version<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/arzhost.com\/blogs\/install-java-11-12-on-centos-7\/#How_to_Set_the_Environment_Variable_JAVA_HOME\" >How to Set the Environment Variable JAVA HOME?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/arzhost.com\/blogs\/install-java-11-12-on-centos-7\/#How_to_Remove_Java_from_CentOS\" >How to Remove Java from CentOS?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/arzhost.com\/blogs\/install-java-11-12-on-centos-7\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"Versions_of_Java\"><\/span><strong>Versions of Java<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><u>There are now four Java platforms accessible:<\/u><\/p>\n<ol>\n<li>Standard Edition of Java (Java SE)<\/li>\n<li>Micro Editions of Java (Java ME)<\/li>\n<li>Enterprise Edition of Java (Java EE)<\/li>\n<li>JavaFX<\/li>\n<\/ol>\n<p><span style=\"color: #000000;\"><strong>How to Install Java 11 &amp; 12 on CentOS 7?<\/strong> <\/span>In this paper, we examine various Java SE packages.<\/p>\n<p>Java Development Kit (Open JDK) and Java Runtime Environment are both free and open-source Java software programs (Open JRE). JDK is used for Java development and programming, whereas JRE is used to run Java-based applications.<\/p>\n<p>Another SE implementation that is available and includes additional commercial capabilities is Java Oracle. The official Oracle JDK can be found on the company&#8217;s website or in a third-party repository. But keep in mind that the program can only be used for non-commercial purposes under its license.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"CentOS_Java_Installation\"><\/span><strong>CentOS Java Installation<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>On your computer, you can install one or more Java packages. By installing a certain version number, you can also choose whatever version you want on your system. Java 11 is the Long-Term Support (LTS) version that is currently the default.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"1_Activate_Openjdk_11\"><\/span><strong>1: Activate Openjdk 11<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><u>1: Update the package repository to ensure you download the newest software:<\/u><\/p>\n<ul>\n<li><code>yum update sudo<\/code><\/li>\n<\/ul>\n<p><u>2: After that, run the Java Development Kit installation command as follows:<\/u><\/p>\n<ul>\n<li><code>Install Java 11-OpenJDK-Devel with sudo yum<\/code><\/li>\n<\/ul>\n<p><u>The downloaded and installed JDK is shown in the output, as seen in the illustration below:<\/u><\/p>\n<h3><span class=\"ez-toc-section\" id=\"2_Activate_OpenJRE_11\"><\/span><strong>2: Activate OpenJRE 11<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><u>A subset of OpenJDK is the Java Runtime Environment 11 (Open JRE 11). Consequently, the command includes both packages:<\/u><\/p>\n<ul>\n<li><code>Install Java 11-OpenJDK with sudo yum<\/code><\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"3_Oracle_Java_11_installation\"><\/span><strong>3: Oracle Java 11 installation<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><u>1: Downloading the official Oracle JDK from the local repository is not possible. The.rpm package must be downloaded from the Java SE Downloads page.<\/u><\/p>\n<p><u>2: Java SE 12 is the most recent version. Oracle Java 11 is the most recent stable version, and it is LTS.<\/u><\/p>\n<ul>\n<li><code>On the website, find Java SE 11.0.3 (LTS) and click DOWNLOAD.<\/code><\/li>\n<\/ul>\n<p><u>3: Use the following command to install the package after the download is finished:<\/u><\/p>\n<ul>\n<li>use the command sudo yum local install jre-VERSION-linux-x64.rpm<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"Make_sure_Java_is_set_up_on_your_computer\"><\/span><strong>Make sure Java is set up on your computer<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><iframe title=\"YouTube video player\" src=\"https:\/\/www.youtube.com\/embed\/d6UyvwFTGWM\" width=\"560\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n<p><u>The command below displays your current Java release and verifies that the installation was successful:<\/u><\/p>\n<ul>\n<li><code>version of Java<\/code><\/li>\n<\/ul>\n<p>If Java was downloaded and installed properly, the output information should resemble the illustration below:<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Install_a_specific_Java_version\"><\/span><strong>Install a specific Java version<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>By altering the command&#8217;s version number, you can also install any other version of Java.<\/p>\n<p><strong><u>1: Setup JDK 8<\/u><\/strong><\/p>\n<ul>\n<li><code>Instead of the usual OpenJDK 11, you might choose to use Open JDK 8.<\/code><\/li>\n<\/ul>\n<p>Enter the following command on the terminal to accomplish this:<\/p>\n<ul>\n<li><code>Install Java 1.8.0-openjdk-devel with sudo yum<\/code><\/li>\n<\/ul>\n<p><strong><u>2: Setup JRE 8<\/u><\/strong><\/p>\n<p>You can install Open JRE 8 as a part of Open JDK 8 by entering the command:<\/p>\n<ul>\n<li><code>Install Java 1.8.0-openjdk with sudo yum<\/code><\/li>\n<\/ul>\n<p><strong><u>3: Oracle Java 12 installation<\/u><\/strong><\/p>\n<p>You must download Oracle Java from its official page, as was already explained.<\/p>\n<p>Simply download the necessary package from their website, then continue with the installation to install the most recent version.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Establishing_the_Default_Java_Version\"><\/span><strong>Establishing the Default Java Version<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>You can choose which version of Java is the default one since various versions of Java can be installed on your machine. To do that;<\/p>\n<p><u>Run the following command to view every installed version on your computer:<\/u><\/p>\n<ul>\n<li><code>alternatives to sudo \u2014config java<\/code><\/li>\n<\/ul>\n<p>Two alternatives to this approach are depicted in the graphic above. The Java 11 number 1, and the number 2, stand in for these options (Java 8).<\/p>\n<p>Enter the corresponding number (in this case, 1 or 2) to alter the default version.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"How_to_Set_the_Environment_Variable_JAVA_HOME\"><\/span><strong>How to Set the Environment Variable JAVA HOME?<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Other applications built using this programming language can access Java&#8217;s installation location with ease by setting the JAVA HOME environment variable.<\/p>\n<p><u>1: Find the location of the Java installation:<\/u><\/p>\n<ul>\n<li><code>update-alternatives sudo java configuration<\/code><\/li>\n<\/ul>\n<p><u>You can find the path to each Java package that is installed on the system in the output.<\/u><\/p>\n<ul>\n<li><code>\/usr\/lib\/jvm\/java-11-openjdk-11.0.3.7-0.el7 6.x86 64\/bin\/java (where OpenJDK 11 is located)<\/code><\/li>\n<li><code>\/usr\/lib\/jvm\/java-1.8.0-openjdk-1.8.0.212.b04-0.el7 6.x86 64\/jre\/bin\/java (where OpenJDK 8 is located) (where OpenJDK 8 is located)<\/code><\/li>\n<\/ul>\n<p><u>2: Once you have seen every path, copy the one that corresponds to your desired Java version.<\/u><\/p>\n<p><u>3: Next, open any text editor and navigate to the. Bash profile. Here&#8217;s an illustration using vim:<\/u><\/p>\n<ul>\n<li><code>.bash profile for vim<\/code><\/li>\n<\/ul>\n<p><u>4: Include a line at the bottom of the file that describes the location of JAVA HOME as follows:<\/u><\/p>\n<ul>\n<li><code>JAVA HOME=\u201d\/your\/installation\/path\/\u201d<\/code><\/li>\n<\/ul>\n<p>For instance, if we copied the Java 11 installation path in the previous step, the text editor will now include the following line:<\/p>\n<ul>\n<li><code>\/usr\/lib\/jvm\/java-11-openjdk-11.0.3.7-0.el7 6.x86 64\/bin\/java<\/code><\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"How_to_Remove_Java_from_CentOS\"><\/span><strong>How to Remove Java from CentOS?<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Use the yum delete command if you need to uninstall any of the installed Java packages.<\/p>\n<p><u>For instance, use the following command to get rid of Open JDK 8:<\/u><\/p>\n<ul>\n<li><code>Remove Java with sudo yum<\/code><\/li>\n<li><code>-1.8.0-openjdk-devel<\/code><\/li>\n<\/ul>\n<p>It will uninstall the package from CentOS if you press &#8220;y&#8221; to confirm the procedure, as shown in the screenshot below:<\/p>\n<ul>\n<li><code>\/usr\/lib\/jvm\/java-11-openjdk-11.0.3.7-0.el7 6.x86 64\/bin\/java<\/code><\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span><strong>Conclusion<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>You have learned How to Install Java 11 &amp; 12 on CentOS 7 through this tutorial.<\/p>\n<p>We also spoke about configuring the home environment variable and modifying the default version. You are now prepared to begin using Java!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to Install Java 11 &amp; 12 on CentOS 7? Java is a very well-liked programming language that is used to create both desktop and lightweight mobile applications. This detailed tutorial will demonstrate how to set up Java on CentOS 7. A user account with sudo privileges Access to the command line\/terminal window The yum [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":6144,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[76],"tags":[],"table_tags":[],"class_list":["post-4620","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java"],"_links":{"self":[{"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/posts\/4620","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/comments?post=4620"}],"version-history":[{"count":4,"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/posts\/4620\/revisions"}],"predecessor-version":[{"id":6145,"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/posts\/4620\/revisions\/6145"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/media\/6144"}],"wp:attachment":[{"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/media?parent=4620"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/categories?post=4620"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/tags?post=4620"},{"taxonomy":"table_tags","embeddable":true,"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/table_tags?post=4620"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}