{"id":33,"date":"2022-06-01T12:19:17","date_gmt":"2025-09-28T05:32:50","guid":{"rendered":""},"modified":"2025-02-02T00:46:14","modified_gmt":"2025-02-01T23:46:14","slug":"how-to-install-java-17-jdk-17-on-linux-debian","status":"publish","type":"post","link":"https:\/\/netcloud24.com\/knowledgebase\/how-to-install-java-17-jdk-17-on-linux-debian\/","title":{"rendered":"Linux VPS &#038; VPS Windows Setup Guide | NetCloud24 Java 17 (JDK 17) on Linux Debian"},"content":{"rendered":"<article>\n<h1>\u00a0<\/h1>\n<div class=\"contributeEdit\" style=\"float: right; width: 450px; max-width: 100%;\">\n<div id=\"tocContainer\">\n<h3>This tutorial exists for these OS versions<\/h3>\n<ul>\n<li><strong>Debian 11 (Bullseye)<\/strong><\/li>\n<\/ul>\n<h3>On this page<\/h3>\n<ol class=\"toc\">\n<li><a href=\"#prerequisites\">Prerequisites<\/a><\/li>\n<li><a href=\"#step-update-the-system\">Step 1. Update the System<\/a><\/li>\n<li><a href=\"#step-installing-java-jdk-on-debian-\">Step 2. Installing Java JDK 17 on Debian 11<\/a><\/li>\n<li><a href=\"#step-configuring-the-environmental-variable\">Step 3. Configuring the Environmental Variable<\/a><\/li>\n<li><a href=\"#step-testing-the-java-installation\">Step 4. Testing the Java Installation<\/a><\/li>\n<li><a href=\"#conclusion\">Conclusion<\/a><\/li>\n<\/ol>\n<\/div>\n<\/div>\n<p>Java is an object-oriented programming language. Java is, by far, the most popular programming language in use throughout the world today. And according to Oracle, it&#8217;s also one of the fastest-growing programming languages in terms of popularity. Companies large and small use Java for a wide range of applications, including banking software, device drivers, embedded systems, healthcare software, industrial automation control systems, weather stations, e-commerce servers and much more.<span id=\"ezoic-pub-ad-placeholder-106\" class=\"pierdolic-idpicker-ad\"><\/span><span id=\"div-gpt-ad-netcloud24_com-box-3-0\" class=\"pierdolic-id\" style=\"position: relative; z-index: 0; display: inline-block; padding: 0; min-height: 90px; min-width: 728px;\"><\/span> Java uses an object-oriented approach which means that everything is treated as an object. In contrast, other languages such as C++ are structured, meaning you have to instruct the program how to do things when writing code instead of having certain pre-defined capabilities built into objects. It is a simple, powerful, and object-oriented programming language which allows the programmer to write both object-oriented code and procedural-oriented code in the same program.<span id=\"ezoic-pub-ad-placeholder-121\" class=\"pierdolic-idpicker-ad\"><\/span><span id=\"div-gpt-ad-netcloud24_com-medrectangle-3-0\" class=\"pierdolic-id\" style=\"position: relative; z-index: 0; display: inline-block; padding: 0; min-height: 90px; min-width: 728px;\"><\/span><\/p>\n<div style=\"width: 336px; float: left; margin: 10px 15px 10px 0; background-color: #fff;\">\u00a0<\/div>\n<p>The Java Development Kit (JDK) is the name of the software development kit (SDK) for the Java programming language, which enables anyone to create both Java applications and applets for running on many operating systems. It is one of three core software programs that are essential to the development of Java applications and is required in order to compile and run Java code. In short, it helps us develop our desired apps. It helps create different types of projects, debug them, compile and run them. It can be frustrating when you first start to install Java on Linux, and it doesn&#8217;t work. This article provides clear instructions for installing Java 17 on Debian 11. You will have your system running in no time.<\/p>\n<h2 id=\"prerequisites\">Prerequisites<\/h2>\n<div id=\"netcloud24_com-link-h-large-1\" class=\"ezo_link_unit_a\">\u00a0<\/p>\n<ul>\n<li>A server running Debian 11 with a working Internet connection.<\/li>\n<li>Enough RAM (memory) to run your system smoothly. At least 3.5 GB should be available.<\/li>\n<li>A non-root user with sudo privileges.<\/li>\n<\/ul>\n<h2 id=\"step-update-the-system\">Step 1. Update the System<\/h2>\n<p>Before you can install anything, you will need to make sure that your system is up-to-date. You can do this by running the following command in the terminal.<\/p>\n<pre class=\"command\">sudo apt update &amp;&amp; sudo apt upgrade -y<\/pre>\n<p>The above command may take a few minutes, depending on the speed of your Internet connection.<\/p>\n<h2 id=\"step-installing-java-jdk-on-debian-\">Step 2. Installing Java JDK 17 on Debian 11<\/h2>\n<p>It&#8217;s recommended to check if Java is already installed on your system. To do so, run the following command in the terminal.<\/p>\n<pre class=\"command\">java -version<\/pre>\n<p>If Java isn&#8217;t installed yet, you will get an output similar to this one. The output shows that no Java installation has been found on the system. Otherwise, if it is installed, you should get a version number.<span id=\"ezoic-pub-ad-placeholder-108\" class=\"pierdolic-idpicker-ad\"><\/span><span id=\"div-gpt-ad-netcloud24_com-medrectangle-4-0\" class=\"pierdolic-id\" style=\"position: relative; z-index: 0; display: inline-block; padding: 0; width: 100%; max-width: 1200px; margin-left: auto!important; margin-right: auto!important; min-height: 90px; min-width: 728px;\"><\/span> \u00a0 The easiest method of installing the JDK is by using the apt package manager. Debian 11\u2019s default repository included Java 17, as shown in the screenshot below.<\/p>\n<pre class=\"command\">sudo apt-cache search openjdk | grep 17<\/pre>\n<p>\u00a0 Run the following command to install Java 17 on Debian 11. We will install both JDK and JRE in order to run Java applications and applets.<\/p>\n<pre class=\"command\">sudo apt install openjdk-17-jdk<\/pre>\n<pre class=\"command\">sudo apt install openjdk-17-jre<\/pre>\n<p>Once the installation is completed, run the following command in order to check if it works properly. If everything works fine, you should get an output similar to the one shown below.<span id=\"ezoic-pub-ad-placeholder-110\" class=\"pierdolic-idpicker-ad\"><\/span><span id=\"div-gpt-ad-netcloud24_com-box-4-0\" class=\"pierdolic-id\" style=\"position: relative; z-index: 0; display: inline-block; padding: 0; width: 100%; max-width: 1200px; margin-left: auto!important; margin-right: auto!important; min-height: 90px; min-width: 728px;\"><\/span><\/p>\n<pre class=\"command\">java -version<\/pre>\n<p>\u00a0 To verify if the JDK is installed properly, we will check the version of javac, which is the Java compiler.<\/p>\n<pre class=\"command\">javac -version<\/pre>\n<p>\u00a0<\/p>\n<h2 id=\"step-configuring-the-environmental-variable\">Step 3. Configuring the Environmental Variable<\/h2>\n<p>Some Java applications require the JAVA_HOME environmental variable in order to run properly. Some programs are very specific in how they are executed. If JAVA_HOME isn&#8217;t set, you&#8217;ll get an error. Setting JAVA_HOME will prevent this problem from arising. First, let&#8217;s determine the path of Java where Java is installed using the update-alternatives command.<span id=\"ezoic-pub-ad-placeholder-111\" class=\"pierdolic-idpicker-ad\"><\/span><\/p>\n<pre class=\"command\">sudo update-alternatives --config java<\/pre>\n<p>This command will output the installation path of Java as you can see in the screenshot below.<\/p>\n<ul>\n<li><em>\/usr\/lib\/jvm\/java-11-openjdk-amd64\/bin\/java<\/em> is the installation path of path of OpenJDK 11<\/li>\n<li><em>usr\/lib\/jvm\/java-17-openjdk-amd64\/bin\/java<\/em> is the installation path of path of OpenJDK 17<\/li>\n<\/ul>\n<p>\u00a0 Copy the path you want to use. Now, open a new environment file with your favorite text editor. We will be using the nano editor in this example.<\/p>\n<pre class=\"command\">sudo nano \/etc\/environment<\/pre>\n<p>You have to paste the path that you&#8217;ve copied at the end of the line export JAVA_HOME=&#8230; into the file, like this. <span id=\"ezoic-pub-ad-placeholder-112\" class=\"pierdolic-idpicker-ad\"><\/span><span class=\"pierdolic-id large-leaderboard-2 large-leaderboard-2112 adtester-container adtester-container-112\" data-ez-name=\"netcloud24_com-large-leaderboard-2\"><span style=\"font-size: 12px; display: block; text-align: center; line-height: 15px;\">Advertisement<\/span><\/span> <span id=\"div-gpt-ad-netcloud24_com-large-leaderboard-2-0\" class=\"pierdolic-id\" style=\"position: relative; z-index: 0; display: block!important; padding: 0; margin-left: auto!important; margin-right: auto!important;\"><\/span> This file will set the JAVA_HOME path of OpenJDK 17 as environmental variables for all users in the system. Save and exit the file by pressing<strong> CTRL+X<\/strong>, <strong>Y<\/strong>, and <strong>Enter<\/strong>. To apply the change, run the following command.<\/p>\n<pre class=\"command\">sudo source \/etc\/environment<\/pre>\n<p>To verify that the path variable has been applied, run the following command.<\/p>\n<pre class=\"command\">echo $JAVA_HOME<\/pre>\n<p>The path should be set to the path of OpenJDK 17, which you have copied above. \u00a0 From now on, you don&#8217;t have to set the JAVA_HOME path every time when using Java programs. Also, if you want to use other OpenJDK versions instead of 17, adapt the path accordingly.<\/p>\n<h2 id=\"step-testing-the-java-installation\">Step 4. Testing the Java Installation<\/h2>\n<p>In this step, we will test if Java was installed properly on your system by creating a simple helloworld Java application, compile, and execute it using the JRE. First, run the following command to create a new directory called helloworld and navigate into it. Here, we will store all our files related to our first Java application.<\/p>\n<pre class=\"command\">mkdir helloworld &amp;&amp; cd helloworld<\/pre>\n<p>Next, create a new file named helloworld.java using your favorite text editor.<\/p>\n<pre class=\"command\">sudo nano helloworld.java<\/pre>\n<p>Now, populate the file with the following content.<span id=\"ezoic-pub-ad-placeholder-113\" class=\"pierdolic-idpicker-ad\"><\/span><\/p>\n<pre class=\"ql-syntax\" spellcheck=\"false\">public class helloworld{\r\n   public static void main(String[] args) {\r\n      System.out.println(\"Netcloud24-Hello World\");\r\n   }\r\n}\r\n<\/pre>\n<p>Save and exit the file by pressing <strong>CTRL+X<\/strong>, <strong>Y<\/strong>, and <strong>Enter<\/strong>. Now that we have created our program, we need to compile the Java source code into bytecode (class file) using the javac compiler.<\/p>\n<pre class=\"command\">javac helloworld.java<\/pre>\n<p>You will get a new file called helloworld.class, which is the compiled Java class file. \u00a0 The command above will only compile the Java source code into bytecode. In order to run the program, we run the java command with the name of our class file as an argument.<\/p>\n<pre class=\"command\">java helloworld<\/pre>\n<p>If everything works well, you&#8217;ll see a message &#8220;Netcloud24-Hello World&#8221; on the screen. \u00a0 You have successfully installed Java. For further reading on the Java language, refer to its official <a href=\"https:\/\/docs.oracle.com\/en\/\">documentation<\/a>.<\/p>\n<h2 id=\"conclusion\">Conclusion<\/h2>\n<p><a href=\"https:\/\/netcloud24.com?language=english\">VPS Windows VPSServer<\/a><\/p>\n<\/div>\n<\/article>\n<p><a href=\"https:\/\/de.netcloud24.com\/\" target=\"_blank\">Windows VPS Deutschland<\/a><\/p>\n<p><a href=\"https:\/\/es.netcloud24.com\/\" target=\"_blank\">Windows VPS Espa\u00f1a<\/a><\/p>\n<p><a href=\"https:\/\/nl.netcloud24.com\/\" target=\"_blank\">Windows VPS Nederland<\/a><\/p>\n<p><a href=\"https:\/\/it.netcloud24.com\/\" target=\"_blank\">Windows VPS Italia<\/a><\/p>\n<p><a href=\"https:\/\/pt.netcloud24.com\/\" target=\"_blank\">Windows VPS Portugal<\/a><\/p>\n<p><a href=\"https:\/\/it.netcloud24.com\/\" target=\"_blank\">VPS Windows Italia<\/a><\/p>\n<p><a href=\"https:\/\/ie.netcloud24.com\" target=\"_blank\">Windows VPS<\/a><\/p>\n<p><a href=\"https:\/\/ie.netcloud24.com\" target=\"_blank\">Windows VPS<\/a><\/p>\n<p><a href=\"https:\/\/ie.netcloud24.com\" target=\"_blank\">Windows VPS Sverige<\/a><\/p>\n<p><a href=\"https:\/\/ie.netcloud24.com\" target=\"_blank\">Windows VPS Norge<\/a><\/p>\n<p><a href=\"https:\/\/ie.netcloud24.com\" target=\"_blank\">Windows VPS<\/a><\/p>\n<p><a href=\"https:\/\/ie.netcloud24.com\" target=\"_blank\">Windows VPS T\u00fcrkiye<\/a><\/p>\n<p><a href=\"https:\/\/ie.netcloud24.com\" target=\"_blank\">Windows RDS (Remote Desktop Services)<\/a><\/p>\n<p><a href=\"https:\/\/ie.netcloud24.com\" target=\"_blank\">Windows VPS<\/a><\/p>\n<div class=\"post-author-box\" style=\"border-top:1px solid #ddd;margin-top:20px;padding-top:15px;\">\n<p><strong>Author:<\/strong> \u0141ukasz Bodziony<\/p>\n<p><strong>Website:<\/strong> <a href=\"https:\/\/ca.netcloud24.com\" target=\"_blank\" rel=\"dofollow\">Windows VPS<\/a><\/p>\n<p><em>\u0141ukasz Bodziony is the CEO and founder of <a href=\"https:\/\/netcloud24.com\" target=\"_blank\" rel=\"dofollow\">NETCLOUD24<\/a>, a global VPS hosting brand proudly originating from Poland. With extensive experience in cloud computing, virtualization, and server management, he delivers high-performance <strong>Windows VPS<\/strong> and <strong>Remote Desktop Services (RDS)<\/strong> solutions to clients across Europe, North America, and beyond.<\/em><\/p>\n<p><em>His expertise covers a wide range of technologies, including <strong>Microsoft Azure<\/strong>, <strong>Proxmox VE<\/strong>, <strong>Amazon Web Services (AWS)<\/strong>, and numerous other virtualization and cloud platforms.<\/em><\/p>\n<p><em>Beyond running his hosting business, \u0141ukasz also provides <strong>professional paid server configuration and optimization services<\/strong> for companies and individuals. Outside of work, he is dedicated to caring for his children and building a secure future for them.<\/em><\/p>\n<p><em>If you are interested in working with him or need expert assistance with your hosting, cloud environment, or server setup, feel free to reach out via <a href=\"https:\/\/ca.netcloud24.com\" target=\"_blank\" rel=\"dofollow\">Windows VPS<\/a>.<\/em><\/p>\n<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u00a0 This tutorial exists for these OS versions Debian 11 (Bullseye) On this page Prerequisites Step 1. Update the System Step 2. Installing Java JDK 17 on Debian\u2026<\/p>\n","protected":false},"author":1,"featured_media":3421,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_seopress_robots_primary_cat":"","_seopress_titles_title":"","_seopress_titles_desc":"","_seopress_robots_index":"","footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[],"tags":[14,12,11,23,20,21,22,17,7,8,6,10,18,19,15,24,16,5,13,9],"class_list":["post-33","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","tag-cheapvps","tag-cloudvps","tag-hostingvps","tag-rds","tag-rdscal","tag-remotedesktop","tag-remotedesktopvps","tag-servervps","tag-ukvps","tag-virtualserver","tag-vpshosting","tag-vpsserver","tag-vpssolutions","tag-vpswindows","tag-vpswithwindows","tag-windowsrds","tag-windowsserver","tag-windowsvps","tag-windowsvpshosting","tag-windowsvpsuk"],"jetpack_publicize_connections":[],"_links":{"self":[{"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/33","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/comments?post=33"}],"version-history":[{"count":0,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/33\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/media\/3421"}],"wp:attachment":[{"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/media?parent=33"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/categories?post=33"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/tags?post=33"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}