{"id":6164,"date":"2018-12-25T22:55:03","date_gmt":"2018-12-25T22:55:03","guid":{"rendered":"https:\/\/www.appservgrid.com\/paw92\/?p=6164"},"modified":"2018-12-28T22:54:20","modified_gmt":"2018-12-28T22:54:20","slug":"install-oracle-jdk-11-on-ubuntu-linux-hint","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2018\/12\/25\/install-oracle-jdk-11-on-ubuntu-linux-hint\/","title":{"rendered":"Install Oracle JDK 11 on Ubuntu \u2013 Linux Hint"},"content":{"rendered":"<p>The full form of JDK is Java Development Kit. It is used to write and test Java programs. Recently, JDK 11 came out. It is the latest version of JDK LTS (Long Term Support) release.<\/p>\n<p>In this article, I will show you how to install Oracle JDK 11 on Ubuntu. I will be using Ubuntu 18.04 LTS for the demonstration. But it should work on any LTS version of Ubuntu. So, let\u2019s get started.<\/p>\n<p>Oracle JDK 11 is not available in the official package repository of Ubuntu. But you can easily download it from the official website of Oracle and install it on Ubuntu.<\/p>\n<p>First, visit the official page of Java SE at <a href=\"https:\/\/www.oracle.com\/technetwork\/java\/javase\/overview\/index.html\">https:\/\/www.oracle.com\/technetwork\/java\/javase\/overview\/index.html<\/a><\/p>\n<p>Once the page loads, click on Downlaods as marked in the screenshot below.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/12\/1-34.png\" alt=\"\" width=\"1140\" height=\"644\" \/><\/p>\n<p>Now, from the Java SE 11.x (LTS) section, click on DOWNLOAD as marked in the screenshot below. At the time of this writing, the latest version of JDK 11 is 11.0.1.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/12\/2-31.png\" alt=\"\" width=\"1140\" height=\"644\" \/><\/p>\n<p>Now, scroll down a little bit and click on Accept License Agreement as marked in the screenshot below.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/12\/3-29.png\" alt=\"\" width=\"1140\" height=\"644\" \/><\/p>\n<p>Now that you\u2019ve accepted the Oracle Technology Network License Agreement for Oracle Java Standard Edition, you are ready to download Oracle JDK 11. To download Oracle JDK 11 for Ubuntu, click on the DEB file link as marked in the screenshot below.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/12\/4-28.png\" alt=\"\" width=\"1140\" height=\"644\" \/><\/p>\n<p>Your browser should prompt you to save the Oracle JDK 11 DEB package file. Select Save File and click on OK.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/12\/5-30.png\" alt=\"\" width=\"1140\" height=\"644\" \/><\/p>\n<p>Your download should start. It may take a while to finish.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/12\/6-28.png\" alt=\"\" width=\"1140\" height=\"644\" \/><\/p>\n<h2>Installing Oracle JDK 11:<\/h2>\n<p>Once the download is complete, navigate to the directory where your browser saved the DEB package file. Usually, it is the ~\/Downloads directory in your login users HOME directory.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/12\/7-29.png\" alt=\"\" width=\"1000\" height=\"115\" \/><\/p>\n<p>As you can see, jdk-11.0.1_linux-x64_bin.deb package file is there.<\/p>\n<p><u>NOTE:<\/u> The package file name may be different by the time you read this article. Make sure you replace the package file name with yours from now.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/12\/8-27.png\" alt=\"\" width=\"1140\" height=\"159\" \/><\/p>\n<p>Now, install Oracle JDK 11 with the following command:<\/p>\n<p>$ sudo dpkg -i jdk-11.0.1_linux-x64_bin.deb<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/12\/9-25.png\" alt=\"\" width=\"1140\" height=\"102\" \/><\/p>\n<p>Now, type in your login user\u2019s password and press &lt;Enter&gt;.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/12\/10-25.png\" alt=\"\" width=\"1140\" height=\"126\" \/><\/p>\n<p>Oracle JDK 11 should be installed.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/12\/11-24.png\" alt=\"\" width=\"1140\" height=\"255\" \/><\/p>\n<h3>Adding Oracle JDK 11 to the PATH:<\/h3>\n<p>The Oracle JDK 11 DEB package file installs Oracle JDK 11 in \/usr\/lib\/jvm directory. It is not in the PATH by default. So, we have to manually add it to the PATH of Ubuntu.<\/p>\n<p>First, find out the directory name where the Oracle JDK 11 is installed with the following command:<\/p>\n<p>As you can see, the directory name is jdk-11.0.1\/ in my case. It may be different for you. Make sure to replace it with your from now on.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/12\/12-24.png\" alt=\"\" width=\"937\" height=\"143\" \/><\/p>\n<p>Now, create a new file \/etc\/profile.d\/jdk11.sh with the following command:<\/p>\n<p>$ sudo nano \/etc\/profile.d\/jdk11.sh<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/12\/13-23.png\" alt=\"\" width=\"1004\" height=\"93\" \/><\/p>\n<p>An empty file should be opened.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/12\/14-22.png\" alt=\"\" width=\"1010\" height=\"451\" \/><\/p>\n<p>Now, add the following lines to the file.<\/p>\n<p>export JAVA_HOME=&#8221;\/usr\/lib\/jvm\/jdk-11.0.1&#8243;<br \/>\nexport PATH=&#8221;$PATH:$\/bin&#8221;<\/p>\n<p><u>NOTE:<\/u> Make sure you change jdk-11.0.1 to the directory name you have.<\/p>\n<p>Finally, the file looks as follows. Now, press &lt;Ctrl&gt; + x and then press y followed by &lt;Enter&gt; to save the file.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/12\/15-22.png\" alt=\"\" width=\"1087\" height=\"448\" \/><\/p>\n<p>Now, restart your computer with the following command:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/12\/16-21.png\" alt=\"\" width=\"1010\" height=\"99\" \/><\/p>\n<p>Once your computer boots, open a Terminal and run the following commands to verify whether JAVA_HOME variable is correctly set and Oracle JDK 11 is on the PATH.<\/p>\n<p>$ echo $JAVA_HOME<br \/>\n$ echo $PATH<\/p>\n<p>As you can see, JAVA_HOME and PATH variables are correctly set.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/12\/17-18.png\" alt=\"\" width=\"1060\" height=\"234\" \/><\/p>\n<p>Now, run the following command to check whether JDK 11 is working.<\/p>\n<p>As you can see, I can run the javac binary without any problem. So, JDK 11 is working.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/12\/18-16.png\" alt=\"\" width=\"1044\" height=\"149\" \/><\/p>\n<h3>Compiling a Java Program with Oracle JDK 11:<\/h3>\n<p>Now, I am going to write a simple java program to test whether we can compile and run it with Oracle JDK 11.<\/p>\n<p>Now, create a file Hello.java and type in the following lines in it.<\/p>\n<p>public class Hello\u00a0<span class=\"br0\">{<\/span><br \/>\npublic\u00a0<span class=\"kw4\">static<\/span>\u00a0<span class=\"kw4\">void<\/span>\u00a0main<span class=\"br0\">(<\/span>String<span class=\"br0\">[<\/span><span class=\"br0\">]<\/span>\u00a0args<span class=\"br0\">)<\/span>\u00a0<span class=\"br0\">{<\/span><br \/>\nSystem.<span class=\"me1\">out<\/span>.<span class=\"me1\">println<\/span><span class=\"br0\">(<\/span><span class=\"st0\">&#8220;Welcome to LinuxHint!&#8221;<\/span><span class=\"br0\">)<\/span><span class=\"sy0\">;<\/span><br \/>\n<span class=\"br0\">}<\/span><br \/>\n<span class=\"br0\">}<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/12\/19-12.png\" alt=\"\" width=\"1110\" height=\"460\" \/><\/p>\n<p>Now, to compile Hello.java source file, open a Terminal and navigate to the directory where your Hello.java source file is saved and run the following command:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/12\/20-13.png\" alt=\"\" width=\"994\" height=\"147\" \/><\/p>\n<p>A new file Hello.class should be generated as you can see in the screenshot below. It is called a Java class file. Java class file contains Java bytecodes that the JVM (Java Virtual Machine) can run.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/12\/21-13.png\" alt=\"\" width=\"988\" height=\"190\" \/><\/p>\n<p>Now, run Hello.class Java class file as follows:<\/p>\n<p><u>NOTE:<\/u> Type in only the filename without .class extension. Otherwise, it won\u2019t work.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/12\/22-12.png\" alt=\"\" width=\"991\" height=\"88\" \/><\/p>\n<p>The correct output is displayed as you can see in the screenshot below.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/12\/23-12.png\" alt=\"\" width=\"992\" height=\"134\" \/><\/p>\n<p>So, that\u2019s how you install Oracle JDK 11 on Ubuntu. Thanks for reading this article.<\/p>\n<p><a href=\"https:\/\/linuxhint.com\/install_oracle_jdk11_ubuntu\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The full form of JDK is Java Development Kit. It is used to write and test Java programs. Recently, JDK 11 came out. It is the latest version of JDK LTS (Long Term Support) release. In this article, I will show you how to install Oracle JDK 11 on Ubuntu. I will be using Ubuntu &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2018\/12\/25\/install-oracle-jdk-11-on-ubuntu-linux-hint\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Install Oracle JDK 11 on Ubuntu \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-6164","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\/6164","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=6164"}],"version-history":[{"count":2,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/6164\/revisions"}],"predecessor-version":[{"id":6782,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/6164\/revisions\/6782"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=6164"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=6164"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=6164"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}