{"id":645,"date":"2019-07-06T12:00:00","date_gmt":"2019-07-06T12:00:00","guid":{"rendered":"http:\/\/kabiliravi.com\/?page_id=645"},"modified":"2019-07-21T13:48:24","modified_gmt":"2019-07-21T13:48:24","slug":"install-java-on-centos-fedora","status":"publish","type":"page","link":"http:\/\/kabiliravi.com\/index.php\/software\/programming\/my-java-tutorial\/install-java\/linux-unix\/install-java-on-centos-fedora\/","title":{"rendered":"Install Java on CentOS\/Fedora"},"content":{"rendered":"\n<p>Installing Java on both CentOS and Fedora are quite similar, since they both supports <strong>YUM<\/strong> for their package management and installer tool.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Install OpenJDK 12 on Fedora 30 \/CentOS 7<\/h2>\n\n\n\n<p>You can use <strong>yum search<\/strong> to search for the openjdk version you are planning to install.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ yum search openjdk<\/pre>\n\n\n\n<p>In Fedora, you can search for <strong>java-latest-openjdk<\/strong> keyword and you should be able to find <em>&#8220;java-latest-openjdk.x86_64 : OpenJDK Runtime Environment 12&#8221;<\/em> if you are going to install 64-bit JDK or you can go for 32-bit JDK with <em>&#8220;java-latest-openjdk.i686 : OpenJDK Runtime Environment 12&#8221;<\/em>. Here is the command to install 64-bit on Fedora<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ yum install java-latest-openjdk.x86_64<\/pre>\n\n\n\n<p>YUM shows you a confirmation text with a transaction summary of the openjdk dependencies packages are being installed as pre-requisite packages for openjdk.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Last metadata expiration check: 0:02:33 ago on Sat 06 Jul 2019 11:15:09 AM EDT.\n Dependencies resolved.\n  Package                                               Architecture                    Version                                                Repository                        Size\n Installing:\n  java-latest-openjdk                                   x86_64                          1:12.0.1.12-1.rolling.fc30                             updates                          223 k\n Installing dependencies:\n  gtk-update-icon-cache                                 x86_64                          3.24.9-1.fc30                                          updates                           31 k\n  java-latest-openjdk-headless                          x86_64                          1:12.0.1.12-1.rolling.fc30                             updates                           39 M\n  libtiff                                               x86_64                          4.0.10-5.fc30                                          updates                          167 k\n  adwaita-cursor-theme                                  noarch                          3.32.0-1.fc30                                          fedora                           644 k\n  adwaita-icon-theme                                    noarch                          3.32.0-1.fc30                                          fedora                            11 M\n  at-spi2-atk                                           x86_64                          2.32.0-1.fc30                                          fedora                            78 k\n  ...\n  xorg-x11-fonts-Type1                                  noarch                          7.5-21.fc30                                            fedora                           517 k\n Installing weak dependencies:\n  gtk3                                                  x86_64                          3.24.9-1.fc30                                          updates                          4.5 M\n  dconf                                                 x86_64                          0.32.0-1.fc30                                          fedora                            94 k\n Transaction Summary\n Install  48 Packages\n Total download size: 60 M\n Installed size: 257 M\n Is this ok [y\/N]:<\/pre>\n\n\n\n<p>You can type <strong>y<\/strong> character and enter to accept to proceed installation. It will start downloading the dependencies like this:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Is this ok [y\/N]: y\n Downloading Packages:\n (1\/48): gtk-update-icon-cache-3.24.9-1.fc30.x86_64.rpm                                                                                               150 kB\/s |  31 kB     00:00\n (2\/48): java-latest-openjdk-12.0.1.12-1.rolling.fc30.x86_64.rpm                                                                                      591 kB\/s | 223 kB     00:00\n (3\/48): libtiff-4.0.10-5.fc30.x86_64.rpm                                                                                                             1.8 MB\/s | 167 kB     00:00\n (4\/48): gtk3-3.24.9-1.fc30.x86_64.rpm                                                                                                                5.8 MB\/s | 4.5 MB     00:00\n (5\/48): adwaita-cursor-theme-3.32.0-1.fc30.noarch.rpm                                                                                                1.9 MB\/s | 644 kB     00:00\n ...<\/pre>\n\n\n\n<p>And it might prompt you to proceed for certain packages if they need GPG Key updating. You can have a switch of <strong>-y<\/strong> for auto confirmation of those pauses.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">(47\/48): xorg-x11-fonts-Type1-7.5-21.fc30.noarch.rpm                                                                                                 2.6 MB\/s | 517 kB     00:00\n (48\/48): java-latest-openjdk-headless-12.0.1.12-1.rolling.fc30.x86_64.rpm                                                                             10 MB\/s |  39 MB     00:03\n Total                                                                                                                                                 12 MB\/s |  60 MB     00:05\n warning: \/var\/cache\/dnf\/updates-d6521d96a82a4d6a\/packages\/gtk-update-icon-cache-3.24.9-1.fc30.x86_64.rpm: Header V3 RSA\/SHA256 Signature, key ID cfc659b9: NOKEY\n Fedora 30 - x86_64 - Updates                                                                                                                         109 kB\/s | 1.6 kB     00:00\n Importing GPG key 0xCFC659B9:\n  Userid     : \"Fedora (30) <a href=\"mailto:fedora-30-primary@fedoraproject.org\">fedora-30-primary@fedoraproject.org<\/a>\"\n  Fingerprint: F1D8 EC98 F241 AAF2 0DF6 9420 EF3C 111F CFC6 59B9\n  From       : \/etc\/pki\/rpm-gpg\/RPM-GPG-KEY-fedora-30-x86_64\n Is this ok [y\/N]:<\/pre>\n\n\n\n<p>Type <strong>y<\/strong> character again and enter and you will see the installing progress like.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Total                                                                                                                                                 12 MB\/s |  60 MB     00:05\n warning: \/var\/cache\/dnf\/updates-d6521d96a82a4d6a\/packages\/gtk-update-icon-cache-3.24.9-1.fc30.x86_64.rpm: Header V3 RSA\/SHA256 Signature, key ID cfc659b9: NOKEY\n Fedora 30 - x86_64 - Updates                                                                                                                         109 kB\/s | 1.6 kB     00:00\n Importing GPG key 0xCFC659B9:\n  Userid     : \"Fedora (30) <a href=\"mailto:fedora-30-primary@fedoraproject.org\">fedora-30-primary@fedoraproject.org<\/a>\"\n  Fingerprint: F1D8 EC98 F241 AAF2 0DF6 9420 EF3C 111F CFC6 59B9\n  From       : \/etc\/pki\/rpm-gpg\/RPM-GPG-KEY-fedora-30-x86_64\n Is this ok [y\/N]: y\n Key imported successfully\n Running transaction check\n Transaction check succeeded.\n Running transaction test\n Transaction test succeeded.\n Running transaction\n   Running scriptlet: copy-jdk-configs-3.7-3.fc30.noarch                                                                                                                          1\/1\n   Running scriptlet: java-latest-openjdk-headless-1:12.0.1.12-1.rolling.fc30.x86_64                                                                                              1\/1\n   Preparing        :                                                                                                                                                             1\/1\n   Installing       : libjpeg-turbo-2.0.2-1.fc30.x86_64                                                                                                                          1\/48\n   Installing       : libXfixes-5.0.3-9.fc30.x86_64                                                                                                                              2\/48\n   Installing       : libwayland-client-1.17.0-1.fc30.x86_64                                                                                                                     3\/48\n   Installing       : libXi-1.7.9-9.fc30.x86_64\n...<\/pre>\n\n\n\n<p>And after installing each package and verifying their installation<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">...\n\nVerifying        : rest-0.8.1-5.fc30.x86_64                                                                                                                                  44\/48\n   Verifying        : ttmkfdir-3.0.9-56.fc30.x86_64                                                                                                                             45\/48\n   Verifying        : tzdata-java-2019a-1.fc30.noarch                                                                                                                           46\/48\n   Verifying        : xorg-x11-font-utils-1:7.5-41.fc30.x86_64                                                                                                                  47\/48\n   Verifying        : xorg-x11-fonts-Type1-7.5-21.fc30.noarch                                                                                                                   48\/48\n Installed:\n   java-latest-openjdk-1:12.0.1.12-1.rolling.fc30.x86_64        gtk3-3.24.9-1.fc30.x86_64                                             dconf-0.32.0-1.fc30.x86_64\n   gtk-update-icon-cache-3.24.9-1.fc30.x86_64                   java-latest-openjdk-headless-1:12.0.1.12-1.rolling.fc30.x86_64        libtiff-4.0.10-5.fc30.x86_64\n   adwaita-cursor-theme-3.32.0-1.fc30.noarch                    adwaita-icon-theme-3.32.0-1.fc30.noarch                               at-spi2-atk-2.32.0-1.fc30.x86_64\n   at-spi2-core-2.32.1-2.fc30.x86_64                            atk-2.32.0-1.fc30.x86_64                                              colord-libs-1.4.4-1.fc30.x86_64\n   copy-jdk-configs-3.7-3.fc30.noarch                           fribidi-1.0.5-2.fc30.x86_64                                           gdk-pixbuf2-modules-2.38.1-1.fc30.x86_64\n   graphite2-1.3.10-7.fc30.x86_64                               harfbuzz-2.3.1-1.fc30.x86_64                                          hicolor-icon-theme-0.17-5.fc30.noarch\n   jasper-libs-2.0.14-8.fc30.x86_64                             javapackages-filesystem-5.3.0-4.fc30.noarch                           jbigkit-libs-2.1-16.fc30.x86_64\n   lcms2-2.9-5.fc30.x86_64                                      libXcomposite-0.4.4-16.fc30.x86_64                                    libXcursor-1.1.15-5.fc30.x86_64\n   libXdamage-1.1.4-16.fc30.x86_64                              libXfixes-5.0.3-9.fc30.x86_64                                         libXft-2.3.2-12.fc30.x86_64\n   libXi-1.7.9-9.fc30.x86_64                                    libXinerama-1.1.4-3.fc30.x86_64                                       libXrandr-1.5.1-9.fc30.x86_64\n   libXtst-1.2.3-9.fc30.x86_64                                  libdatrie-0.2.9-9.fc30.x86_64                                         libepoxy-1.5.3-2.fc30.x86_64\n   libfontenc-1.1.3-10.fc30.x86_64                              libgusb-0.3.0-4.fc30.x86_64                                           libjpeg-turbo-2.0.2-1.fc30.x86_64\n   libthai-0.1.28-2.fc30.x86_64                                 libwayland-client-1.17.0-1.fc30.x86_64                                libwayland-cursor-1.17.0-1.fc30.x86_64\n   libwayland-egl-1.17.0-1.fc30.x86_64                          lua-5.3.5-5.fc30.x86_64                                               lua-posix-33.3.1-13.fc30.x86_64\n   pango-1.43.0-3.fc30.x86_64                                   rest-0.8.1-5.fc30.x86_64                                              ttmkfdir-3.0.9-56.fc30.x86_64\n   tzdata-java-2019a-1.fc30.noarch                              xorg-x11-font-utils-1:7.5-41.fc30.x86_64                              xorg-x11-fonts-Type1-7.5-21.fc30.noarch\n Complete!<\/pre>\n\n\n\n<p>You can check the version of the java installed using <strong>java -version<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ java -version\n openjdk version \"12.0.1\" 2019-04-16\n OpenJDK Runtime Environment 19.3 (build 12.0.1+12)\n OpenJDK 64-Bit Server VM 19.3 (build 12.0.1+12, mixed mode, sharing)<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Install Java SE (Oracle JDK) 12 on Fedora 30 \/ CentOS 7 <\/h2>\n\n\n\n<p>Installing Java SE or Oracle JDK on Fedora\/CentOS is partially manual. That means you need to download the <strong>.rpm<\/strong> package manually using a downloader cli tool like wget:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ wget --no-cookies --no-check-certificate --header \"Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie\" \"https:\/\/download.oracle.com\/otn-pub\/java\/jdk\/12.0.1+12\/69cfe15208a647278a19ef0990eea691\/jdk-12.0.1_linux-x64_bin.rpm\"<\/pre>\n\n\n\n<p>Here is the log if the download is successful. Make sure the size of file download is more than 100MB. If the size of the file is around kilobytes that means you have messed up with Oracle License Agreement that you have passed as Header Cookie in your wget request.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">--2019-07-06 13:36:45--  https:\/\/download.oracle.com\/otn-pub\/java\/jdk\/12.0.1+12\/69cfe15208a647278a19ef0990eea691\/jdk-12.0.1_linux-x64_bin.rpm\n Resolving download.oracle.com (download.oracle.com)\u2026 23.43.160.14\n Connecting to download.oracle.com (download.oracle.com)|23.43.160.14|:443\u2026 connected.\n HTTP request sent, awaiting response\u2026 302 Moved Temporarily\n Location: https:\/\/edelivery.oracle.com\/otn-pub\/java\/jdk\/12.0.1+12\/69cfe15208a647278a19ef0990eea691\/jdk-12.0.1_linux-x64_bin.rpm [following]\n --2019-07-06 13:36:45--  https:\/\/edelivery.oracle.com\/otn-pub\/java\/jdk\/12.0.1+12\/69cfe15208a647278a19ef0990eea691\/jdk-12.0.1_linux-x64_bin.rpm\n Resolving edelivery.oracle.com (edelivery.oracle.com)\u2026 2001:559:19:f8a3::366, 2001:559:19:f881::366, 104.106.216.77\n Connecting to edelivery.oracle.com (edelivery.oracle.com)|2001:559:19:f8a3::366|:443\u2026 connected.\n HTTP request sent, awaiting response\u2026 302 Moved Temporarily\n Location: http:\/\/download.oracle.com\/otn-pub\/java\/jdk\/12.0.1+12\/69cfe15208a647278a19ef0990eea691\/jdk-12.0.1_linux-x64_bin.rpm?AuthParam=1562503038_ceb254a8d1b6fee78bc7cb626aa366ab [following]\n --2019-07-06 13:36:46--  http:\/\/download.oracle.com\/otn-pub\/java\/jdk\/12.0.1+12\/69cfe15208a647278a19ef0990eea691\/jdk-12.0.1_linux-x64_bin.rpm?AuthParam=1562503038_ceb254a8d1b6fee78bc7cb626aa366ab\n Connecting to download.oracle.com (download.oracle.com)|23.43.160.14|:80\u2026 connected.\n HTTP request sent, awaiting response\u2026 301 Moved Permanently\n Location: https:\/\/download.oracle.com\/otn-pub\/java\/jdk\/12.0.1+12\/69cfe15208a647278a19ef0990eea691\/jdk-12.0.1_linux-x64_bin.rpm?AuthParam=1562503038_ceb254a8d1b6fee78bc7cb626aa366ab [following]\n --2019-07-06 13:36:46--  https:\/\/download.oracle.com\/otn-pub\/java\/jdk\/12.0.1+12\/69cfe15208a647278a19ef0990eea691\/jdk-12.0.1_linux-x64_bin.rpm?AuthParam=1562503038_ceb254a8d1b6fee78bc7cb626aa366ab\n Connecting to download.oracle.com (download.oracle.com)|23.43.160.14|:443\u2026 connected.\n HTTP request sent, awaiting response\u2026 200 OK\n Length: 170440632 (163M) [application\/x-redhat-package-manager]\n Saving to: \u2018jdk-12.0.1_linux-x64_bin.rpm\u2019\n jdk-12.0.1_linux-x64_bin.rpm                  100%[==============================================================================================&gt;] 162.54M  2.74MB\/s    in 56s\n 2019-07-06 13:37:42 (2.91 MB\/s) - \u2018jdk-12.0.1_linux-x64_bin.rpm\u2019 saved [170440632\/170440632]<\/pre>\n\n\n\n<p>Finally using following <strong>rpm<\/strong> command with <strong>-Uvh<\/strong> switch to ignore the verification of dependencies. <\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>The trick is since you already installed openjdk using yum command, it has already installed the dependencies that are required for Java SE or Oracle JDK. I did not dig to find the Oracle JDK dependencies as pre-requisite for its installation, since I am not fan of non FOSS (Free Open Source Software). If something failed on running java or javac command complaining about a missing dependency, you need to google the error and find the solution.<\/p><\/blockquote>\n\n\n\n<p> However, you can install that .rpm local package.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ sudo rpm -Uvh jdk-12.0.1_linux-x64_bin.rpm <\/pre>\n\n\n\n<p>You will get a warning because you have not provided a RPM key <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">warning: jdk-12.0.1_linux-x64_bin.rpm: Header V3 RSA\/SHA256 Signature, key ID ec551f03: NOKEY\n Verifying\u2026                          ################################# [100%]\n Preparing\u2026                          ################################# [100%]\n Updating \/ installing\u2026\n    1:jdk-12.0.1-2000:12.0.1-ga        ################################# [100%]<\/pre>\n\n\n\n<p>If you check java version, you will see Oracle JDK overrides your openjdk path.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ java -version\n java version \"12.0.1\" 2019-04-16\n Java(TM) SE Runtime Environment (build 12.0.1+12)\n Java HotSpot(TM) 64-Bit Server VM (build 12.0.1+12, mixed mode, sharing)<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Use jEnv to Switch JDKs<\/h2>\n\n\n\n<p>You can refer to&nbsp;<a href=\"http:\/\/kabiliravi.com\/index.php\/software\/programming\/my-java-tutorial\/install-java\/switching-jdks-using-jenv\/\">Switch JDKs using jEnv<\/a>&nbsp;page, if you have multiple JDKs installed on your machine, and you need to switch between them fast and without going and set $JAVE_HOME and $PATH environment variables<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Installing Java on both CentOS and Fedora are quite similar, since they both supports YUM for their package management and installer tool. Install OpenJDK 12 on Fedora 30 \/CentOS 7 You can use yum search to search for the openjdk version you are planning to install. $ yum search openjdk In Fedora, you can search [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":634,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"ngg_post_thumbnail":0,"footnotes":""},"class_list":["post-645","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"http:\/\/kabiliravi.com\/index.php\/wp-json\/wp\/v2\/pages\/645","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/kabiliravi.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/kabiliravi.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/kabiliravi.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/kabiliravi.com\/index.php\/wp-json\/wp\/v2\/comments?post=645"}],"version-history":[{"count":13,"href":"http:\/\/kabiliravi.com\/index.php\/wp-json\/wp\/v2\/pages\/645\/revisions"}],"predecessor-version":[{"id":704,"href":"http:\/\/kabiliravi.com\/index.php\/wp-json\/wp\/v2\/pages\/645\/revisions\/704"}],"up":[{"embeddable":true,"href":"http:\/\/kabiliravi.com\/index.php\/wp-json\/wp\/v2\/pages\/634"}],"wp:attachment":[{"href":"http:\/\/kabiliravi.com\/index.php\/wp-json\/wp\/v2\/media?parent=645"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}