{"id":1623,"date":"2021-02-11T06:30:50","date_gmt":"2021-02-11T06:30:50","guid":{"rendered":"https:\/\/linuxbuz.com\/?p=1623"},"modified":"2024-03-10T08:38:56","modified_gmt":"2024-03-10T08:38:56","slug":"check-java-version-linux","status":"publish","type":"post","link":"https:\/\/linuxbuz.com\/linuxhowto\/check-java-version-linux","title":{"rendered":"How to Check Java Version On Linux | Ubuntu\/Debian\/CentOS"},"content":{"rendered":"<p style=\"text-align: justify;\">Java is one of the most popular and widely used programming languages around the globe. If you are a Java developer then you must have a knowledge of <strong>&#8220;how to check java version&#8221;<\/strong>. There are several methods to check which Java version installed in your system.<\/p>\n<p>If you don&#8217;t know how to install Java, you should read my guide on <a href=\"https:\/\/linuxbuz.com\/linuxhowto\/install-java-8-ubuntu\" target=\"_blank\" rel=\"noopener\">How to Install Java on Ubuntu 20.04<\/a>.<\/p>\n<p style=\"text-align: justify;\">In the post, we will show you how to <strong>check java version<\/strong> on CentOS, Ubuntu and Debian operating systems.<\/p>\n<p><script async src=\"https:\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script><\/p>\n<p><!-- in-article-ad2 --><ins class=\"adsbygoogle\" style=\"display: inline-block; width: 728px; height: 90px;\" data-ad-client=\"ca-pub-5304214417414899\" data-ad-slot=\"8597014438\"><\/ins> <script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Prerequisites\"><\/span><span style=\"color: #3c314d;\">Prerequisites<\/span><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li>A server running Debian 10.<\/li>\n<li>A root password is set up in your server.<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"Check_Java_Version_on_Linux\"><\/span><span style=\"color: #3c314d;\">Check Java Version on Linux<\/span><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">If you want to check the <strong>Java<\/strong> version on Ubuntu, Debian or CentOS operating systems, open a command-line terminal and run the following command:<\/p>\n<pre class=\"brush: bash; light: false; title: ; toolbar: true; notranslate\" title=\"\">java -version<\/pre>\n<p>This will display the installed version of Java as shown below:<\/p>\n<pre class=\"brush: bash; light: false; title: ; toolbar: true; notranslate\" title=\"\">java -version\nopenjdk version \"11.0.9.1\" 2020-11-04\nOpenJDK Runtime Environment (build 11.0.9.1+1-Ubuntu-0ubuntu1.20.04)\nOpenJDK 64-Bit Server VM (build 11.0.9.1+1-Ubuntu-0ubuntu1.20.04, mixed mode, sharing)\n<\/pre>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-1626\" src=\"https:\/\/linuxbuz.com\/wp-content\/uploads\/2021\/02\/check-java-version-ubuntu.png\" alt=\"check java version ubuntu\" width=\"723\" height=\"96\" srcset=\"https:\/\/linuxbuz.com\/wp-content\/uploads\/2021\/02\/check-java-version-ubuntu.png 723w, https:\/\/linuxbuz.com\/wp-content\/uploads\/2021\/02\/check-java-version-ubuntu-300x40.png 300w\" sizes=\"(max-width: 723px) 100vw, 723px\" \/><\/p>\n<p>You can also check the <strong>Java<\/strong> <strong>compiler<\/strong> version using the javac command as shown below:<\/p>\n<pre class=\"brush: bash; light: false; title: ; toolbar: true; notranslate\" title=\"\">javac -version<\/pre>\n<p>You should see the <strong>Java compiler version<\/strong> in the following output:<\/p>\n<pre class=\"brush: bash; light: false; title: ; toolbar: true; notranslate\" title=\"\">javac 11.0.9.1<\/pre>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-1627\" src=\"https:\/\/linuxbuz.com\/wp-content\/uploads\/2021\/02\/check-javac-version.png\" alt=\"check javac version linux\" width=\"675\" height=\"53\" srcset=\"https:\/\/linuxbuz.com\/wp-content\/uploads\/2021\/02\/check-javac-version.png 675w, https:\/\/linuxbuz.com\/wp-content\/uploads\/2021\/02\/check-javac-version-300x24.png 300w\" sizes=\"(max-width: 675px) 100vw, 675px\" \/><\/p>\n<div align=\"center\"><script async src=\"https:\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script> <!-- In-article-ad3 --> <ins class=\"adsbygoogle\" style=\"display: inline-block; width: 468px; height: 60px;\" data-ad-client=\"ca-pub-5304214417414899\" data-ad-slot=\"4350007035\"><\/ins> <script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script><\/div>\n<h2><span class=\"ez-toc-section\" id=\"Check_Java_Version_Using_the_Java_Installation_Path\"><\/span><span style=\"color: #3c314d;\">Check Java Version Using the Java Installation Path<\/span><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">You can also check the <strong>java<\/strong> <strong>version<\/strong> with the help of Java installation path. There is two way to find the Java installation directory or path.<\/p>\n<p>The first method to find the Java installation path with the following command:<\/p>\n<pre class=\"brush: bash; light: false; title: ; toolbar: true; notranslate\" title=\"\">update-alternatives --list java<\/pre>\n<p>This will display the complete path of the Java as shown below:<\/p>\n<pre class=\"brush: bash; light: false; title: ; toolbar: true; notranslate\" title=\"\">\/usr\/lib\/jvm\/java-11-openjdk-amd64\/bin\/java<\/pre>\n<p><strong>Note:<\/strong> For CentOS and RHEL operating system, run the following command:<\/p>\n<pre class=\"brush: bash; light: false; title: ; toolbar: true; notranslate\" title=\"\">update-alternatives --list<\/pre>\n<p>You can also use the <strong>whereis<\/strong> command to check the Java path.<\/p>\n<p>Run the <strong>whereis<\/strong> command as shown below:<\/p>\n<pre class=\"brush: bash; light: false; title: ; toolbar: true; notranslate\" title=\"\">whereis java<\/pre>\n<p>You should see the following output:<\/p>\n<pre class=\"brush: bash; light: false; title: ; toolbar: true; notranslate\" title=\"\">java: \/usr\/bin\/java \/usr\/share\/java \/usr\/share\/man\/man1\/java.1.gz\n<\/pre>\n<p>Next, run the ls command to list the content of \/usr\/bin\/java:<\/p>\n<pre class=\"brush: bash; light: false; title: ; toolbar: true; notranslate\" title=\"\">ls -l \/usr\/bin\/java<\/pre>\n<p>You should see the following output:<\/p>\n<pre class=\"brush: bash; light: false; title: ; toolbar: true; notranslate\" title=\"\">lrwxrwxrwx 1 root root 22 Feb  5 04:50 \/usr\/bin\/java -&gt; \/etc\/alternatives\/java\n<\/pre>\n<p>In the above output, you should see that \/usr\/bin\/java point to symbolic link \/etc\/alternatives\/java.<\/p>\n<p>Now, run the ls command again to list the content of <strong>\/etc\/alternatives\/java<\/strong>.<\/p>\n<pre class=\"brush: bash; light: false; title: ; toolbar: true; notranslate\" title=\"\">ls -l \/etc\/alternatives\/java<\/pre>\n<p>This will display the complete path of the Java as shown below:<\/p>\n<pre class=\"brush: bash; light: false; title: ; toolbar: true; notranslate\" title=\"\">lrwxrwxrwx 1 root root 43 Feb  5 04:50 \/etc\/alternatives\/java -&gt; \/usr\/lib\/jvm\/java-11-openjdk-amd64\/bin\/java\n<\/pre>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-1629\" src=\"https:\/\/linuxbuz.com\/wp-content\/uploads\/2021\/02\/check-java-version-by-searching-path-1.png\" alt=\"check java version using path\" width=\"1020\" height=\"126\" srcset=\"https:\/\/linuxbuz.com\/wp-content\/uploads\/2021\/02\/check-java-version-by-searching-path-1.png 1020w, https:\/\/linuxbuz.com\/wp-content\/uploads\/2021\/02\/check-java-version-by-searching-path-1-300x37.png 300w, https:\/\/linuxbuz.com\/wp-content\/uploads\/2021\/02\/check-java-version-by-searching-path-1-768x95.png 768w\" sizes=\"(max-width: 1020px) 100vw, 1020px\" \/><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Check_Java_Version_by_Searching_in_Installed_Package_List\"><\/span><span style=\"color: #3c314d;\">Check Java Version by Searching in Installed Package List<\/span><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">You can also check the Java version to list installed packages and search for <strong>Java<\/strong>. For Ubuntu and Debian operating systems, follow the below steps:<\/p>\n<p>You can use either <strong>apt<\/strong> or <strong>dpkg<\/strong> command to list all installed packages.<\/p>\n<p>List all installed packages and search for Java using the <strong>apt<\/strong> command:<\/p>\n<pre class=\"brush: bash; light: false; title: ; toolbar: true; notranslate\" title=\"\">apt list --installed | grep -i openjdk<\/pre>\n<p>You should see the installed version of <strong>Java<\/strong> in the following output:<\/p>\n<pre class=\"brush: bash; light: false; title: ; toolbar: true; notranslate\" title=\"\">openjdk-11-jdk-headless\/focal-updates,focal-security,now 11.0.9.1+1-0ubuntu1~20.04 amd64 [installed,automatic]\nopenjdk-11-jdk\/focal-updates,focal-security,now 11.0.9.1+1-0ubuntu1~20.04 amd64 [installed,automatic]\nopenjdk-11-jre-headless\/focal-updates,focal-security,now 11.0.9.1+1-0ubuntu1~20.04 amd64 [installed,automatic]\nopenjdk-11-jre\/focal-updates,focal-security,now 11.0.9.1+1-0ubuntu1~20.04 amd64 [installed,automatic]\n<\/pre>\n<p>List all installed packages and search for <strong>Java<\/strong> using the <strong>dpkg<\/strong> command:<\/p>\n<pre class=\"brush: bash; light: false; title: ; toolbar: true; notranslate\" title=\"\">dpkg -l | grep -i openjdk<\/pre>\n<p>You should see the installed version of <strong>Java<\/strong> in the following output:<\/p>\n<pre class=\"brush: bash; light: false; title: ; toolbar: true; notranslate\" title=\"\">ii  openjdk-11-jdk:amd64           11.0.9.1+1-0ubuntu1~20.04         amd64        OpenJDK Development Kit (JDK)\nii  openjdk-11-jdk-headless:amd64  11.0.9.1+1-0ubuntu1~20.04         amd64        OpenJDK Development Kit (JDK) (headless)\nii  openjdk-11-jre:amd64           11.0.9.1+1-0ubuntu1~20.04         amd64        OpenJDK Java runtime, using Hotspot JIT\nii  openjdk-11-jre-headless:amd64  11.0.9.1+1-0ubuntu1~20.04         amd64        OpenJDK Java runtime, using Hotspot JIT (headless)\n<\/pre>\n<p>For CentOS and RHEL operating systems, follow the below steps:<\/p>\n<p>You can use <strong>yum<\/strong> or <strong>dnf<\/strong> command to list all installed packages and search for Java as shown below:<\/p>\n<pre class=\"brush: bash; light: false; title: ; toolbar: true; notranslate\" title=\"\">yum list installed | grep -i openjdk<\/pre>\n<p>This will display the installed version of <strong>Java<\/strong> as shown below:<\/p>\n<pre class=\"brush: bash; light: false; title: ; toolbar: true; notranslate\" title=\"\">java-11-openjdk.x86_64               1:11.0.9.11-3.el8_3                      @AppStream\njava-11-openjdk-devel.x86_64         1:11.0.9.11-3.el8_3                      @AppStream\njava-11-openjdk-headless.x86_64      1:11.0.9.11-3.el8_3                      @AppStream\n<\/pre>\n<p><script async src=\"https:\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script><\/p>\n<p><!-- In-article-ad4 --><ins class=\"adsbygoogle\" style=\"display: inline-block; width: 728px; height: 90px;\" data-ad-client=\"ca-pub-5304214417414899\" data-ad-slot=\"5069026486\"><\/ins> <script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span><span style=\"color: #3c314d;\">Conclusion<\/span><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">In the above guide, you learned a different method of how to <strong>check the Java version<\/strong> on Linux. You can now any of the above methods to check the Java version.<\/p>\n<div align=\"center\"><script async src=\"https:\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script> <!-- comment4 --> <ins class=\"adsbygoogle\" style=\"display: inline-block; width: 468px; height: 60px;\" data-ad-client=\"ca-pub-5304214417414899\" data-ad-slot=\"5958414828\"><\/ins> <script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script><\/div>\n<div align=\"center\"><script async src=\"https:\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script> <!-- comment1 --> <ins class=\"adsbygoogle\" style=\"display: inline-block; width: 200px; height: 200px;\" data-ad-client=\"ca-pub-5304214417414899\" data-ad-slot=\"2676084863\"><\/ins> <!-- comment2 --> <ins class=\"adsbygoogle\" style=\"display: inline-block; width: 200px; height: 200px;\" data-ad-client=\"ca-pub-5304214417414899\" data-ad-slot=\"8970030479\"><\/ins> <!-- comment3 --> <ins class=\"adsbygoogle\" style=\"display: inline-block; width: 200px; height: 200px;\" data-ad-client=\"ca-pub-5304214417414899\" data-ad-slot=\"7162124785\"><\/ins> <script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Java is one of the most popular and widely used programming languages around the globe. If you are a Java developer then you must have a knowledge of &#8220;how to &hellip; <\/p>\n","protected":false},"author":1,"featured_media":1625,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"two_page_speed":[],"footnotes":""},"categories":[12],"tags":[],"class_list":["post-1623","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linuxhowto"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/linuxbuz.com\/wp-json\/wp\/v2\/posts\/1623","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxbuz.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxbuz.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxbuz.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxbuz.com\/wp-json\/wp\/v2\/comments?post=1623"}],"version-history":[{"count":0,"href":"https:\/\/linuxbuz.com\/wp-json\/wp\/v2\/posts\/1623\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxbuz.com\/wp-json\/wp\/v2\/media\/1625"}],"wp:attachment":[{"href":"https:\/\/linuxbuz.com\/wp-json\/wp\/v2\/media?parent=1623"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxbuz.com\/wp-json\/wp\/v2\/categories?post=1623"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxbuz.com\/wp-json\/wp\/v2\/tags?post=1623"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}