{"id":17860,"date":"2023-07-14T23:19:43","date_gmt":"2023-07-14T20:19:43","guid":{"rendered":"https:\/\/kifarunix.com\/?p=17860"},"modified":"2024-03-10T10:22:56","modified_gmt":"2024-03-10T07:22:56","slug":"install-java-17-lts-on-debian","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-java-17-lts-on-debian\/","title":{"rendered":"Install Java 17 LTS on Debian 12"},"content":{"rendered":"\n<p>This is a step by step guide on how to quickly install Java 17 LTS on Debian 12.<\/p>\n\n\n\n<div class=\"wp-block-rank-math-toc-block\" id=\"rank-math-toc\"><h2>Table of Contents<\/h2><nav><ul><li><a href=\"#installing-java-17-lts-on-debian-12\">Installing Java 17 LTS on Debian 12<\/a><ul><li><a href=\"#open-jdk-vs-oracle-jdk\">OpenJDK vs Oracle JDK<\/a><\/li><li><a href=\"#jdk-vs-jre\">JDK vs JRE<\/a><\/li><li><a href=\"#install-open-jdk-17-lts-on-debian-12\">Install OpenJDK 17 LTS on Debian 12<\/a><\/li><li><a href=\"#check-java-version-on-debian\">Check Java Version on Debian<\/a><\/li><li><a href=\"#how-to-set-default-java-version-on-debian-12\">How to Set Default Java Version on Debian 12<\/a><\/li><li><a href=\"#set-java-home-environment-variable\">Set JAVA HOME Environment Variable<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"installing-java-17-lts-on-debian-12\">Installing Java 17 LTS on Debian 12<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"open-jdk-vs-oracle-jdk\">OpenJDK vs Oracle JDK<\/h3>\n\n\n\n<p>There are two versions of <a href=\"https:\/\/www.oracle.com\/java\/\" target=\"_blank\" rel=\"noreferrer noopener\">Java<\/a>, OpenJDK and Oracle JDK;<\/p>\n\n\n\n<p>While both are products of Oracle, OpenJDK is an opensource version while Oracle JDK is a enterprise product that requires a commercial license to use.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"jdk-vs-jre\">JDK vs JRE<\/h3>\n\n\n\n<p>JRE stands for Java Runtime Environment while JDK stands for Java Development Kit.<\/p>\n\n\n\n<p><em>JDK is a superset of JRE, and contains everything that is in JRE, plus tools such as the compilers and debuggers necessary for developing applets and applications.<\/em><\/p>\n\n\n\n<p><em>JRE provides the libraries, the Java Virtual Machine (JVM), and other components to run applets and applications written in the Java programming language<\/em>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"install-open-jdk-17-lts-on-debian-12\">Install OpenJDK 17 LTS on Debian 12<\/h3>\n\n\n\n<p>OpenJDK 17 packages are available on the default Debian 12 Universe repositories.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apt update<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>apt-cache search openjdk | grep 17<\/code><\/pre>\n\n\n\n<p>Sample output;<\/p>\n\n\n\n<pre class=\"scroll-box\"><code>\nopenjdk-17-dbg - Java runtime based on OpenJDK (debugging symbols)\nopenjdk-17-demo - Java runtime based on OpenJDK (demos and examples)\nopenjdk-17-doc - OpenJDK Development Kit (JDK) documentation\nopenjdk-17-jdk - OpenJDK Development Kit (JDK)\nopenjdk-17-jdk-headless - OpenJDK Development Kit (JDK) (headless)\nopenjdk-17-jre - OpenJDK Java runtime, using Hotspot JIT\nopenjdk-17-jre-headless - OpenJDK Java runtime, using Hotspot JIT (headless)\nopenjdk-17-jre-zero - Alternative JVM for OpenJDK, using Zero\nopenjdk-17-source - OpenJDK Development Kit (JDK) source files\nuwsgi-plugin-jvm-openjdk-17 - Java plugin for uWSGI (OpenJDK 17)\nuwsgi-plugin-jwsgi-openjdk-17 - JWSGI plugin for uWSGI (OpenJDK 17)\nuwsgi-plugin-ring-openjdk-17 - Closure\/Ring plugin for uWSGI (OpenJDK 17)\nuwsgi-plugin-servlet-openjdk-17 - JWSGI plugin for uWSGI (OpenJDK 17)\n<\/code><\/pre>\n\n\n\n<p>To install OpenJDK 17 LTS on Debian 12, execute the commands below;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apt install openjdk-17-jdk<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"check-java-version-on-debian\">Check Java Version on Debian<\/h3>\n\n\n\n<p>Confirm the version;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>java --version<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>openjdk 17.0.7 2023-04-18\nOpenJDK Runtime Environment (build 17.0.7+7-Debian-1deb12u1)\nOpenJDK 64-Bit Server VM (build 17.0.7+7-Debian-1deb12u1, mixed mode, sharing)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"how-to-set-default-java-version-on-debian-12\">How to Set Default Java Version on Debian 12<\/h3>\n\n\n\n<p>If you have multiple versions of Java installed and want to set either Java 17 LTS as the default, run the command below;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo update-alternatives --config java<\/code><\/pre>\n\n\n\n<p>If there are other versions of Java installed, the command will list them and their system paths.<\/p>\n\n\n\n<p>You will also see a current default Java version with an asterisk (*).<\/p>\n\n\n\n<p>Choose any number with the respective version of Java you need to make default, type the number and press ENTER to set that specific version as default.<\/p>\n\n\n\n<p>Then when you list again, it should be available;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>update-alternatives --list java<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"set-java-home-environment-variable\">Set JAVA HOME Environment Variable<\/h3>\n\n\n\n<p>Next you can set Java home environment variable of your Java selection by updating the path to the Java version.<\/p>\n\n\n\n<p>For example, current version of Java selected;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>java --version<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>openjdk 17.0.7 2023-04-18\nOpenJDK Runtime Environment (build 17.0.7+7-Debian-1deb12u1)\nOpenJDK 64-Bit Server VM (build 17.0.7+7-Debian-1deb12u1, mixed mode, sharing)<\/code><\/pre>\n\n\n\n<p>The path can be obtained by rerunning the command above or by just running the command below;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>readlink -f \/usr\/bin\/java | sed \"s:\/bin\/java::\"<\/code><\/pre>\n\n\n\n<p>Sample output;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/usr\/lib\/jvm\/java-17-openjdk-amd64<\/code><\/pre>\n\n\n\n<p>Next, update the <strong>\/etc\/environment<\/strong> file to load the environment variables.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>echo \"JAVA_HOME=\/usr\/lib\/jvm\/java-17-openjdk-amd64\" &gt;&gt; \/etc\/environment<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>source \/etc\/environment<\/code><\/pre>\n\n\n\n<p>To confirm the Java home environment variable setting, run the command below;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>echo $JAVA_HOME<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\/usr\/lib\/jvm\/java-17-openjdk-amd64<\/code><\/pre>\n\n\n\n<p>Well, you are good to go. That is all on how to install Java 17 LTS Debian 12.<\/p>\n\n\n\n<p>See other related guides by following the links below;<\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-java-11java-17java-18-on-rocky-linux\/\" target=\"_blank\" rel=\"noreferrer noopener\">Install Java 11|Java 17|Java 18 on Rocky Linux<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-java-11-java-17-java-18-on-ubuntu\/\">Install Java 11|Java 17|Java 18 on Ubuntu 22.04<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is a step by step guide on how to quickly install Java 17 LTS on Debian 12. Installing Java 17 LTS on Debian 12<\/p>\n","protected":false},"author":10,"featured_media":10534,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[121,795],"tags":[7051,7050,7048,7049],"class_list":["post-17860","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howtos","category-java","tag-debian-12-java-17","tag-install-java-17-debian-12","tag-install-java-17-lts-on-debian","tag-java-17-debian-12","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50","resize-featured-image"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/17860"}],"collection":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/comments?post=17860"}],"version-history":[{"count":5,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/17860\/revisions"}],"predecessor-version":[{"id":20813,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/17860\/revisions\/20813"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media\/10534"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=17860"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=17860"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=17860"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}