{"id":8287,"date":"2021-08-22T17:03:59","date_gmt":"2021-08-22T17:03:59","guid":{"rendered":"https:\/\/green.cloud\/docs\/docly-documentation\/content\/how-to-install-java-on-centos-8\/"},"modified":"2026-01-19T00:45:43","modified_gmt":"2026-01-19T00:45:43","slug":"how-to-install-java-on-centos-8","status":"publish","type":"docs","link":"https:\/\/green.cloud\/docs\/how-to-install-java-on-centos-8\/","title":{"rendered":"How to install Java on CentOS 8"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"8287\" class=\"elementor elementor-8287\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-3042658e elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"3042658e\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-2c961329\" data-id=\"2c961329\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-78620dc8 elementor-widget elementor-widget-text-editor\" data-id=\"78620dc8\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Java is a free, open source and one of the most popular programming languages explicitly designed for use in the distributed environment of the internet. There are two different implementations of Java, Oracle Java and OpenJDK. Oracle Java has some additional commercial features while OpenJDK is an open source implementation of the Java Platform.<br \/>In this tutorial, we will show you how to install OpenJDK 8, OpenJDK 11 and Oracle 8 on CentOS 8<\/p><h3><strong>1.Install<\/strong>\u00a0OpenJDK 11<\/h3><p><i>First, search for available versions of OpenJDK in the CentOS 8 repository by running the following command:<\/i><\/p><pre><code>$ dnf search jdk<\/code><\/pre><p>You will see the following output:<\/p><p><img decoding=\"async\" class=\"alignnone wp-image-8289 size-epress-750x375\" src=\"https:\/\/green.cloud\/docs\/wp-content\/uploads\/2021\/08\/java-2-750x375.png\" alt=\"\" \/><\/p><p><i>Now, install OpenJDK 11 with the following command:<\/i><\/p><pre><code>$ dnf install java-11-openjdk-devel.x86_64<\/code><\/pre><p><i>Once the installation is complete, you can verify the installed Java version by running the following command:<\/i><\/p><pre><code>$ java -version<\/code><\/pre><p>You will see the following output:<\/p><p><img decoding=\"async\" class=\"alignnone wp-image-8292 size-epress-360x180\" src=\"https:\/\/green.cloud\/docs\/wp-content\/uploads\/2021\/08\/java1-360x180.png\" alt=\"\" \/><\/p><h3><strong>2. Install<\/strong>\u00a0OpenJDK 8<\/h3><p>Some Java-based applications are only supported on OpenJDK 8. In this case, you will need to install OpenJDK 8 on your server. You can install OpenJDK 8 easily with the following command:<\/p><pre><code>$ dnf install java-1.8.0-openjdk-devel<\/code><\/pre><p>Once the installation is complete, you can verify the installed Java version by running the following command:<\/p><pre><code>$ java -version<\/code><\/pre><p>You will see the following output:<\/p><p><img decoding=\"async\" class=\"alignnone size-epress-360x180 wp-image-8291\" src=\"https:\/\/green.cloud\/docs\/wp-content\/uploads\/2021\/08\/java-3-1-360x180.png\" alt=\"\" \/><\/p><h3>3. Switch between Java versions<\/h3><p>You can also install multiple Java versions in one system and switch between them as per your requirement.<\/p><p>You can run the following command to switch Java version from OpenJDK 8 to OpenJDK 11 as shown below:<\/p><pre><code>$ alternatives --config java<\/code><\/pre><p>You will be asked to provide your desired Java version as shown below:<\/p><p><img decoding=\"async\" class=\"alignnone wp-image-8293 size-epress-360x180\" src=\"https:\/\/green.cloud\/docs\/wp-content\/uploads\/2021\/08\/java-4-360x180.png\" alt=\"\" \/><\/p><p>Enter to keep the current selection[+], or type selection number: 1<br \/>Type 1 and press Enter to switch the Java version.<\/p><p>After changing again, check the current working Java version with the following command:<\/p><pre><code>$ java -version<\/code><\/pre><h3><strong>4.Install Oracle Java 8<\/strong><\/h3><p>First you will need to login to the Oracle Java website and go to the Oracle 8 JDK Download Page. Next, accept the license agreement and download the jdk-8u231-linux-x64.rpm package.<\/p><p>Once the download is complete, run the following command to install Oracle OpenJDK 8:<\/p><pre><code>$ dnf localinstall jdk-8u231-linux-x64.rpm<\/code><\/pre><p>After installing Oracle OpenJDK 8, you can verify the Java version with the following command:<\/p><pre><code>$ java -version<\/code><\/pre><h5 id=\"install-openjdk-\"><a href=\"https:\/\/greencloudvps.com\/billing\/aff.php?aff=2871\"><img decoding=\"async\" class=\"alignnone wp-image-7983 size-full\" src=\"https:\/\/green.cloud\/docs\/wp-content\/uploads\/2021\/08\/2-2.png\" alt=\"\" \/><\/a><\/h5>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>Java is a free, open source and one of the most popular programming languages explicitly designed for use in the distributed environment of the internet. There are two different implementations of Java, Oracle Java and OpenJDK. Oracle Java has some additional commercial features while OpenJDK is an open source implementation of the Java Platform.In this [&hellip;]<\/p>\n","protected":false},"author":19,"featured_media":0,"parent":17817,"menu_order":252,"comment_status":"open","ping_status":"closed","template":"","doc_tag":[],"class_list":["post-8287","docs","type-docs","status-publish","hentry","no-post-thumbnail"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to install Java on CentOS 8 - GreenCloud Documentation<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/green.cloud\/docs\/how-to-install-java-on-centos-8\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to install Java on CentOS 8 - GreenCloud Documentation\" \/>\n<meta property=\"og:description\" content=\"Java is a free, open source and one of the most popular programming languages explicitly designed for use in the distributed environment of the internet. There are two different implementations of Java, Oracle Java and OpenJDK. Oracle Java has some additional commercial features while OpenJDK is an open source implementation of the Java Platform.In this [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/green.cloud\/docs\/how-to-install-java-on-centos-8\/\" \/>\n<meta property=\"og:site_name\" content=\"GreenCloud Documentation\" \/>\n<meta property=\"article:modified_time\" content=\"2026-01-19T00:45:43+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/green.cloud\\\/docs\\\/how-to-install-java-on-centos-8\\\/\",\"url\":\"https:\\\/\\\/green.cloud\\\/docs\\\/how-to-install-java-on-centos-8\\\/\",\"name\":\"How to install Java on CentOS 8 - GreenCloud Documentation\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/green.cloud\\\/docs\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/green.cloud\\\/docs\\\/how-to-install-java-on-centos-8\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/green.cloud\\\/docs\\\/how-to-install-java-on-centos-8\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/green.cloud\\\/docs\\\/wp-content\\\/uploads\\\/2021\\\/08\\\/java-2-750x375.png\",\"datePublished\":\"2021-08-22T17:03:59+00:00\",\"dateModified\":\"2026-01-19T00:45:43+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/green.cloud\\\/docs\\\/how-to-install-java-on-centos-8\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/green.cloud\\\/docs\\\/how-to-install-java-on-centos-8\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/green.cloud\\\/docs\\\/how-to-install-java-on-centos-8\\\/#primaryimage\",\"url\":\"https:\\\/\\\/green.cloud\\\/docs\\\/wp-content\\\/uploads\\\/2021\\\/08\\\/java-2-750x375.png\",\"contentUrl\":\"https:\\\/\\\/green.cloud\\\/docs\\\/wp-content\\\/uploads\\\/2021\\\/08\\\/java-2-750x375.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/green.cloud\\\/docs\\\/how-to-install-java-on-centos-8\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/green.cloud\\\/docs\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"GreenCloud Documents\",\"item\":\"https:\\\/\\\/green.cloud\\\/docs\\\/docs\\\/greencloud-documents\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Linux Operating Systems\",\"item\":\"https:\\\/\\\/green.cloud\\\/docs\\\/linux-operating-systems\\\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"How to install Java on CentOS 8\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/green.cloud\\\/docs\\\/#website\",\"url\":\"https:\\\/\\\/green.cloud\\\/docs\\\/\",\"name\":\"GreenCloud Documentation\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/green.cloud\\\/docs\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to install Java on CentOS 8 - GreenCloud Documentation","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/green.cloud\/docs\/how-to-install-java-on-centos-8\/","og_locale":"en_US","og_type":"article","og_title":"How to install Java on CentOS 8 - GreenCloud Documentation","og_description":"Java is a free, open source and one of the most popular programming languages explicitly designed for use in the distributed environment of the internet. There are two different implementations of Java, Oracle Java and OpenJDK. Oracle Java has some additional commercial features while OpenJDK is an open source implementation of the Java Platform.In this [&hellip;]","og_url":"https:\/\/green.cloud\/docs\/how-to-install-java-on-centos-8\/","og_site_name":"GreenCloud Documentation","article_modified_time":"2026-01-19T00:45:43+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/green.cloud\/docs\/how-to-install-java-on-centos-8\/","url":"https:\/\/green.cloud\/docs\/how-to-install-java-on-centos-8\/","name":"How to install Java on CentOS 8 - GreenCloud Documentation","isPartOf":{"@id":"https:\/\/green.cloud\/docs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/green.cloud\/docs\/how-to-install-java-on-centos-8\/#primaryimage"},"image":{"@id":"https:\/\/green.cloud\/docs\/how-to-install-java-on-centos-8\/#primaryimage"},"thumbnailUrl":"https:\/\/green.cloud\/docs\/wp-content\/uploads\/2021\/08\/java-2-750x375.png","datePublished":"2021-08-22T17:03:59+00:00","dateModified":"2026-01-19T00:45:43+00:00","breadcrumb":{"@id":"https:\/\/green.cloud\/docs\/how-to-install-java-on-centos-8\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/green.cloud\/docs\/how-to-install-java-on-centos-8\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/green.cloud\/docs\/how-to-install-java-on-centos-8\/#primaryimage","url":"https:\/\/green.cloud\/docs\/wp-content\/uploads\/2021\/08\/java-2-750x375.png","contentUrl":"https:\/\/green.cloud\/docs\/wp-content\/uploads\/2021\/08\/java-2-750x375.png"},{"@type":"BreadcrumbList","@id":"https:\/\/green.cloud\/docs\/how-to-install-java-on-centos-8\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/green.cloud\/docs\/"},{"@type":"ListItem","position":2,"name":"GreenCloud Documents","item":"https:\/\/green.cloud\/docs\/docs\/greencloud-documents\/"},{"@type":"ListItem","position":3,"name":"Linux Operating Systems","item":"https:\/\/green.cloud\/docs\/linux-operating-systems\/"},{"@type":"ListItem","position":4,"name":"How to install Java on CentOS 8"}]},{"@type":"WebSite","@id":"https:\/\/green.cloud\/docs\/#website","url":"https:\/\/green.cloud\/docs\/","name":"GreenCloud Documentation","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/green.cloud\/docs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/green.cloud\/docs\/wp-json\/wp\/v2\/docs\/8287","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/green.cloud\/docs\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/green.cloud\/docs\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/green.cloud\/docs\/wp-json\/wp\/v2\/users\/19"}],"replies":[{"embeddable":true,"href":"https:\/\/green.cloud\/docs\/wp-json\/wp\/v2\/comments?post=8287"}],"version-history":[{"count":1,"href":"https:\/\/green.cloud\/docs\/wp-json\/wp\/v2\/docs\/8287\/revisions"}],"predecessor-version":[{"id":18309,"href":"https:\/\/green.cloud\/docs\/wp-json\/wp\/v2\/docs\/8287\/revisions\/18309"}],"up":[{"embeddable":true,"href":"https:\/\/green.cloud\/docs\/wp-json\/wp\/v2\/docs\/17817"}],"wp:attachment":[{"href":"https:\/\/green.cloud\/docs\/wp-json\/wp\/v2\/media?parent=8287"}],"wp:term":[{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/green.cloud\/docs\/wp-json\/wp\/v2\/doc_tag?post=8287"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}