{"id":7098,"date":"2019-01-02T21:20:13","date_gmt":"2019-01-02T21:20:13","guid":{"rendered":"https:\/\/www.appservgrid.com\/paw92\/?p=7098"},"modified":"2019-01-08T11:01:01","modified_gmt":"2019-01-08T11:01:01","slug":"centos-install-openjdk-linux-hint","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/01\/02\/centos-install-openjdk-linux-hint\/","title":{"rendered":"CentOS Install OpenJDK \u2013 Linux Hint"},"content":{"rendered":"<p>When it\u2019s necessary to build your apps or do some programming on Java, it\u2019s always important to have all the necessary tools ready, for example, the compiler (also known as JDK \u2013 Java Development Kit) and the runtime (also known as JRE \u2013 Java Runtime Environment). Note that by default, JDK comes up with JRE, so you don\u2019t have to manually install JRE again.<\/p>\n<p>Of course, Java programs require a special environment to work on. When you compile a Java program, it generates a \u201cjar\u201d package that contains a universal binary form of the app. When you wish to run it, it\u2019s the task of the JRE to read the universal binary and run it smoothly on the current system.<\/p>\n<p>Linux is my favorite platform for programming, especially Java. You can work with both the Oracle Java and the OpenJDK. For Linux, I prefer the OpenJDK one as it\u2019s more convenient on the Linux platform and almost all the major Linux distros integrate with OpenJDK easier than the Oracle counterpart.<\/p>\n<p>CentOS is the open-source and community edition of the well-known and respected RHEL (Red Hat Enterprise Linux). I just got my CentOS machine ready, now I need to set OpenJDK.<\/p>\n<p>Let\u2019s go and enjoy OpenJDK!<\/p>\n<p>There\u2019re 2 separate ways of setting OpenJDK on CentOS \u2013 from the default CentOS repository (OpenJDK 8) and manually downloading and setting the OpenJDK (OpenJDK 11). <a href=\"https:\/\/linuxhint.com\/java-11-new-features\/\">Don\u2019t forget to check out the latest features of Java 11<\/a>!<\/p>\n<h2>Installing from CentOS repo<\/h2>\n<p>Fire up a terminal and make sure that everything is up-to-date \u2013<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2019\/01\/1.png\" alt=\"\" width=\"879\" height=\"249\" \/><\/p>\n<p>Now, run the following command \u2013<\/p>\n<p>yum install java-1.8.0-openjdk<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2019\/01\/2.png\" alt=\"\" width=\"880\" height=\"217\" \/><\/p>\n<h3>Installing OpenJDK manually<\/h3>\n<p>Note that this is not the recommended way of enjoying OpenJDK. Use the previous method unless you REALLY need the latest OpenJDK.<\/p>\n<p>Using this method, you can also<\/p>\n<p><a href=\"https:\/\/jdk.java.net\/11\/\">Download the latest OpenJDK<\/a> \u2013<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2019\/01\/3.png\" alt=\"\" width=\"754\" height=\"379\" \/><\/p>\n<p>Extract the downloaded OpenJDK \u2013<\/p>\n<p>tar -xfvz openjdk-11.0.1_linux-x64_bin.tar.gz &#8211;directory \/usr\/lib\/jvm<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2019\/01\/4.png\" alt=\"\" width=\"865\" height=\"665\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2019\/01\/5.png\" alt=\"\" width=\"867\" height=\"661\" \/><\/p>\n<p>Don\u2019t forget to verify the extraction \u2013<\/p>\n<p>\/usr\/lib\/jvm\/jdk-11.0.1\/bin\/java -version<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2019\/01\/6.png\" alt=\"\" width=\"863\" height=\"128\" \/><\/p>\n<p>It\u2019s time to make the switch to the newer JDK.<\/p>\n<p>sudo sh -c &#8216;for bin in \/usr\/lib\/jvm\/jdk-11.0.1\/bin\/*; do update-alternatives<br \/>\n&#8211;install \/usr\/bin\/$(basename $bin) $(basename $bin) $bin 100; done&#8217;<\/p>\n<p>sudo sh -c &#8216;for bin in \/usr\/lib\/jvm\/jdk-11.0.1\/bin\/*; do update-alternatives<br \/>\n&#8211;set $(basename $bin) $bin; done&#8217;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2019\/01\/7.png\" alt=\"\" width=\"867\" height=\"158\" \/><\/p>\n<p>Now, we will grab \u201cupdate-alternatives\u201d and tell the system to change to the newly set OpenJDK \u2013<\/p>\n<p>sudo update-alternatives &#8211;config java<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2019\/01\/8.png\" alt=\"\" width=\"865\" height=\"288\" \/><\/p>\n<p>Then, select the OpenJDK number that represents the OpenJDK 11 \u2013<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2019\/01\/9.png\" alt=\"\" width=\"863\" height=\"282\" \/><\/p>\n<p>Voila! OpenJDK is now present in the system!<\/p>\n<p>Don\u2019t forget to check out the result of the change \u2013<\/p>\n<p>For Java programming, what\u2019s better than a well-packed IDE? <a href=\"https:\/\/linuxhint.com\/eclipse-java-tutorial\/\">Check out Eclipse \u2013 one of the finest IDEs for Java programmers<\/a>!<\/p>\n<p><a href=\"https:\/\/linuxhint.com\/centos_install_openjdk\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>When it\u2019s necessary to build your apps or do some programming on Java, it\u2019s always important to have all the necessary tools ready, for example, the compiler (also known as JDK \u2013 Java Development Kit) and the runtime (also known as JRE \u2013 Java Runtime Environment). Note that by default, JDK comes up with JRE, &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/01\/02\/centos-install-openjdk-linux-hint\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;CentOS Install OpenJDK \u2013 Linux Hint&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-7098","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/7098","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=7098"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/7098\/revisions"}],"predecessor-version":[{"id":7422,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/7098\/revisions\/7422"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=7098"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=7098"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=7098"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}