{"id":641,"date":"2019-07-06T11:57:50","date_gmt":"2019-07-06T11:57:50","guid":{"rendered":"http:\/\/kabiliravi.com\/?page_id=641"},"modified":"2019-07-21T13:48:25","modified_gmt":"2019-07-21T13:48:25","slug":"install-java-on-debian-ubuntu","status":"publish","type":"page","link":"http:\/\/kabiliravi.com\/index.php\/software\/programming\/my-java-tutorial\/install-java\/linux-unix\/install-java-on-debian-ubuntu\/","title":{"rendered":"Install Java on Debian\/Ubuntu"},"content":{"rendered":"\n<p>To install <strong>OpenJDK<\/strong> or <strong>Oracle JDK<\/strong> on Debian or Ubuntu, the most convenient way is to use their package manager called <a href=\"https:\/\/wiki.debian.org\/Apt\">APT (Advanced Package Tool)<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Install OpenJDK<\/h2>\n\n\n\n<p>The first step is to add the <strong>openjdk<\/strong> APT repository which is <strong>ppa:openjdk-r\/ppa<\/strong> to APT source list. Here is the command for it (Note that you need to be sudo user):<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ sudo add-apt-repository ppa:openjdk-r\/ppa<\/pre>\n\n\n\n<p>After that, update your<strong> <\/strong>APT local repository index using following command<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ sudo apt-get update<\/pre>\n\n\n\n<p>Now if you search for openjdk-12-jdk using apt search, you can find following items<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ sudo apt search openjdk-12-jdk\nSorting\u2026 Done\nFull Text Search\u2026 Done\nopenjdk-12-jdk\/xenial 12.0.1+12-4~16.04.1 amd64\n  OpenJDK Development Kit (JDK)\nopenjdk-12-jdk-headless\/xenial 12.0.1+12-4~16.04.1 amd64\n  OpenJDK Development Kit (JDK) (headless)<\/pre>\n\n\n\n<p>Using <strong>apt install<\/strong> command you can install it<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ sudo apt install openjdk-12-jdk\n Reading package lists\u2026 Done\n Building dependency tree\n Reading state information\u2026 Done\n The following additional packages will be installed:\n   openjdk-12-jdk-headless openjdk-12-jre openjdk-12-jre-headless\n Suggested packages:\n   openjdk-12-demo openjdk-12-source visualvm libnss-mdns fonts-ipafont-gothic fonts-ipafont-mincho fonts-wqy-microhei | fonts-wqy-zenhei fonts-indic\n The following NEW packages will be installed:\n   openjdk-12-jdk openjdk-12-jdk-headless openjdk-12-jre openjdk-12-jre-headless\n 0 upgraded, 4 newly installed, 0 to remove and 212 not upgraded.\n Need to get 256 MB of archives.\n After this operation, 417 MB of additional disk space will be used.\n Do you want to continue? [Y\/n] Y\n Get:1 http:\/\/ppa.launchpad.net\/openjdk-r\/ppa\/ubuntu xenial\/main amd64 openjdk-12-jre-headless amd64 12.0.1+12-4~16.04.1 [41.7 MB]\n Get:2 http:\/\/ppa.launchpad.net\/openjdk-r\/ppa\/ubuntu xenial\/main amd64 openjdk-12-jre amd64 12.0.1+12-4~16.04.1 [34.3 kB]\n Get:3 http:\/\/ppa.launchpad.net\/openjdk-r\/ppa\/ubuntu xenial\/main amd64 openjdk-12-jdk-headless amd64 12.0.1+12-4~16.04.1 [215 MB]\n Get:4 http:\/\/ppa.launchpad.net\/openjdk-r\/ppa\/ubuntu xenial\/main amd64 openjdk-12-jdk amd64 12.0.1+12-4~16.04.1 [10.9 kB]\n Fetched 256 MB in 27s (9,223 kB\/s)\n Selecting previously unselected package openjdk-12-jre-headless:amd64.\n (Reading database \u2026 64423 files and directories currently installed.)\n Preparing to unpack \u2026\/openjdk-12-jre-headless_12.0.1+12-4~16.04.1_amd64.deb \u2026\n Unpacking openjdk-12-jre-headless:amd64 (12.0.1+12-4~16.04.1) \u2026\n Selecting previously unselected package openjdk-12-jre:amd64.\n Preparing to unpack \u2026\/openjdk-12-jre_12.0.1+12-4~16.04.1_amd64.deb \u2026\n Unpacking openjdk-12-jre:amd64 (12.0.1+12-4~16.04.1) \u2026\n Selecting previously unselected package openjdk-12-jdk-headless:amd64.\n Preparing to unpack \u2026\/openjdk-12-jdk-headless_12.0.1+12-4~16.04.1_amd64.deb \u2026\n Unpacking openjdk-12-jdk-headless:amd64 (12.0.1+12-4~16.04.1) \u2026\n Selecting previously unselected package openjdk-12-jdk:amd64.\n Preparing to unpack \u2026\/openjdk-12-jdk_12.0.1+12-4~16.04.1_amd64.deb \u2026\n Unpacking openjdk-12-jdk:amd64 (12.0.1+12-4~16.04.1) \u2026\n Processing triggers for hicolor-icon-theme (0.15-0ubuntu1.1) \u2026\n Processing triggers for mime-support (3.59ubuntu1) \u2026\n Setting up openjdk-12-jre-headless:amd64 (12.0.1+12-4~16.04.1) \u2026\n Setting up openjdk-12-jre:amd64 (12.0.1+12-4~16.04.1) \u2026\n Setting up openjdk-12-jdk-headless:amd64 (12.0.1+12-4~16.04.1) \u2026\n Setting up openjdk-12-jdk:amd64 (12.0.1+12-4~16.04.1) \u2026<\/pre>\n\n\n\n<p>Using java -version you can check the installed java version<\/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 (build 12.0.1+12-Ubuntu-416.04.1)\n OpenJDK 64-Bit Server VM (build 12.0.1+12-Ubuntu-416.04.1, mixed mode)<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Install Oracle JDK<\/h2>\n\n\n\n<p>In order to install Oracle JDK, you need to add <strong>ppa:linuxuprising\/java<\/strong> APT repository. <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ sudo add-apt-repository ppa:linuxuprising\/java<\/pre>\n\n\n\n<p>Now after running <strong>apt update<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ sudo apt update<\/pre>\n\n\n\n<p>You can go and find <strong>oracle-java12-installer<\/strong> using <strong>apt search<\/strong> command<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ sudo apt search oracle-java12-installer\n Sorting\u2026 Done\n Full Text Search\u2026 Done\n oracle-java12-installer\/xenial,now 12.0.1-1~linuxuprising1 amd64 [installed]\n   Oracle Java(TM) Development Kit (JDK) 12<\/pre>\n\n\n\n<p>And using <strong>apt install<\/strong> you can install it<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ sudo apt install oracle-java12-installer\n Reading package lists\u2026 Done\n Building dependency tree\n Reading state information\u2026 Done\n The following additional packages will be installed:\n   oracle-java12-set-default\n Suggested packages:\n   binfmt-support visualvm ttf-baekmuk | ttf-unfonts | ttf-unfonts-core ttf-kochi-gothic | ttf-sazanami-gothic ttf-kochi-mincho | ttf-sazanami-mincho ttf-arphic-uming\n   firefox | firefox-2 | iceweasel | mozilla-firefox | iceape-browser | mozilla-browser | epiphany-gecko | epiphany-webkit | epiphany-browser | galeon | midbrowser\n   | moblin-web-browser | xulrunner | xulrunner-1.9 | konqueror | chromium-browser | midori | google-chrome\n The following NEW packages will be installed:\n   oracle-java12-installer oracle-java12-set-default\n 0 upgraded, 2 newly installed, 0 to remove and 212 not upgraded.\n Need to get 0 B\/36.5 kB of archives.\n After this operation, 138 kB of additional disk space will be used.\n Do you want to continue? [Y\/n]<\/pre>\n\n\n\n<p>After you type <strong>Y<\/strong> character to continue installation, you will see two screens in regards to Oracle License Agreement policy. In order to continue and install Oracle JDK make sure you read that and if you agree click on <strong>Agree<\/strong> choice on the second screen<\/p>\n\n\n\nngg_shortcode_0_placeholder\n\n\n\n<p>  Using <em>java -version<\/em>, you will see that Oracle JDK has been installed with this name: <strong>Java HotSpot(TM) 64-Bit Server VM<\/strong>. If you already installed openjdk 12 or other versions of java, this installer will override the Java path and JAVA_HOME variable to its location. <\/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 <a href=\"http:\/\/kabiliravi.com\/index.php\/software\/programming\/my-java-tutorial\/install-java\/switching-jdks-using-jenv\/\">Switch JDKs using jEnv<\/a> 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>To install OpenJDK or Oracle JDK on Debian or Ubuntu, the most convenient way is to use their package manager called APT (Advanced Package Tool). Install OpenJDK The first step is to add the openjdk APT repository which is ppa:openjdk-r\/ppa to APT source list. Here is the command for it (Note that you need to [&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-641","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"http:\/\/kabiliravi.com\/index.php\/wp-json\/wp\/v2\/pages\/641","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=641"}],"version-history":[{"count":14,"href":"http:\/\/kabiliravi.com\/index.php\/wp-json\/wp\/v2\/pages\/641\/revisions"}],"predecessor-version":[{"id":685,"href":"http:\/\/kabiliravi.com\/index.php\/wp-json\/wp\/v2\/pages\/641\/revisions\/685"}],"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=641"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}