{"id":3265,"date":"2025-02-19T20:31:57","date_gmt":"2025-02-19T20:31:57","guid":{"rendered":"https:\/\/foghosting.com\/how-do-i-install-java-on-ubuntu-fog-hosting\/"},"modified":"2025-02-19T20:31:57","modified_gmt":"2025-02-19T20:31:57","slug":"how-do-i-install-java-on-ubuntu-fog-hosting","status":"publish","type":"post","link":"https:\/\/foghosting.com\/blog\/how-do-i-install-java-on-ubuntu-fog-hosting\/","title":{"rendered":"How Do I install Java on Ubuntu? &#8211; Fog Hosting"},"content":{"rendered":"<div>\n<h2><span id=\"Introduction\">Introduction\u00a0<\/span><\/h2>\n<p>A high-level language is a significant requirement behind building software and applications. Computers only understand machine language, which is a low-binary language. We can\u2019t develop software and applications through machine language. This is where high-level languages like Java come into the picture.\u00a0<\/p>\n<p>You may question how a computer understands a high-level language. Well, compilers do the work of translating high-level languages to low-level languages. To use Java, you need to first install it on your operating system. A good thing about Java is that it is highly compatible.<\/p>\n<p>You will discover easy steps to <strong>install Java on Ubuntu<\/strong>, which is an open-source operating system. Also, we have included content related to installing a specific version of Java and its uninstallation. Let\u2019s start the reading process by reviewing Java versions quickly.<\/p>\n<h2><span id=\"Java_Versions\">Java Versions\u00a0<\/span><\/h2>\n<p>Have you ever visited a gym? If yes, then you can easily relate the Java platform to a gym. A gym is a place to maintain your fitness packed with an instructor and all the equipment. Similarly, a Java platform is a place where you can get all the equipment to build your application and software. To clearly understand this platform, we must go through all three divisions.\u00a0<\/p>\n<h3><span id=\"JVM_Java_Virtual_Machine\">JVM (Java Virtual Machine)<\/span><\/h3>\n<p>It is like a machine that reads the bytecode and executes it. It helps in the proper execution of instructions in machine language.<\/p>\n<h3><span id=\"JDK_Java_Development_Kit\">JDK (Java Development Kit)<\/span><\/h3>\n<p>Just like you have equipment at the gym, a JDK is a toolbox. JDK consists of all the tools you require to develop an application or\u00a0software.\u00a0<\/p>\n<h3><span id=\"JSL_Java_Standard_Library\">JSL (Java Standard Library)<\/span><\/h3>\n<p>This library consists of various pre-written codes, which are helpful\u00a0for developers. Imagine not having to write specific codes from\u00a0scratch and simply use the code blocks to develop your\u00a0application.\u00a0<\/p>\n<h2><span id=\"Installing_Java_on_Ubuntu\">Installing Java on Ubuntu\u00a0<\/span><\/h2>\n<p>We will now follow the below steps to install Java on Ubuntu. The most basic thing you have to do before starting the installation is to update your package list. Just press Ctrl+Alt+T and open the terminal window to run the command \u2018sudo apt update.\u2019 Your package list is updated, and now we will move forward to the first step.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/p>\n<h3><span id=\"Install_JDK\"><strong>\u00a0Install JDK\u00a0<\/strong><\/span><\/h3>\n<p>The default package repository of Ubuntu is OpenJDK, which is an\u00a0open-source platform to run Java. You can use the below command to install JRE (Java Runtime Environment), which is primarily made\u00a0for users who want to run Java applications.<\/p>\n<pre><code>sudo apt install default-jre<\/code><\/pre>\n<figure><\/figure>\n<p>Developers need JDK (Java Development Kit), a whole toolbox for developing software and application. Run the below command to install JDK.<\/p>\n<pre><code>sudo apt install default-jdk<\/code><\/pre>\n<figure><\/figure>\n<h3><span id=\"Install_Oracle_Java_11\">\u00a0Install Oracle Java 11\u00a0<\/span><\/h3>\n<p>If you want to install the official Oracle JDK for Java, it\u2019s essential to know that you can\u2019t use package managers for automatic installation due to their licensing agreement. You\u2019ll have to make an Oracle account and download the JDK manually. Then, add a new package repository for the desired version and use apt to install it with the help of a third-party installation script. Remember that the Oracle JDK includes the JRE, so you don\u2019t have to install it separately.<\/p>\n<h3><span id=\"Download_Oracle_Java_from_Linux_Uprising_PPA\"><strong>Download Oracle Java from Linux Uprising PPA<\/strong><\/span><\/h3>\n<p>In the terminal window, write the below command to add the Linux Uprising PPA.<\/p>\n<pre><code>sudo add-apt-repository ppa:linuxuprising\/java<\/code><\/pre>\n<figure><\/figure>\n<p>After you enter the above command, the terminal will prompt you to enter your password. Now you need to update the package list to make the package manager aware of the new repository. You can update it with the following command.<\/p>\n<pre><code>sudo apt update<\/code><\/pre>\n<p>When the package list is updated properly, you are ready to <strong>install your chosen Oracle Java version on Ubuntu<\/strong>. You can use the following command.<\/p>\n<pre><code>sudo apt install oracle-java11-installer<\/code><\/pre>\n<p>In the above command, we have used Java 11; you can replace it with the choice of your version. At last, if you want to verify the installation of your version, you can use the below command.<\/p>\n<pre><code>'java -version.'<\/code><\/pre>\n<figure><\/figure>\n<h2><span id=\"How_to_Set_Default_Java_Version\">How to Set Default Java Version?<\/span><\/h2>\n<p>If you use Ubuntu and have multiple Java versions installed, there is a simple way to designate which one to use as the default. You can make use of the update-alternatives command that allows you to set Java 11 as the primary version. Simply execute the following command to make the change.<\/p>\n<pre><code>sudo update-alternatives --config java<\/code><\/pre>\n<figure><\/figure>\n<p>After this, all you need to do is select the version.<\/p>\n<h2><span id=\"How_to_Set_JAVA_HOME_Environment_Variable\">How to Set JAVA_HOME Environment Variable\u00a0<\/span><\/h2>\n<p>The Java_home environment variable is majorly used for setting the location of the <strong>Java installation on Ubuntu<\/strong>. You may wonder what the importance of the location here is. Well, many applications and tools require the correct location of Java installation. Now let\u2019s check the process of setting the Java_home environment variable.<\/p>\n<ul>\n<li>Locate Java on your system with this command.<\/li>\n<\/ul>\n<pre><code>sudo update-alternatives --config Java<\/code><\/pre>\n<figure><\/figure>\n<ul>\n<li>After you enter this command, a list of Java versions will appear; simply copy the preferred one.<\/li>\n<\/ul>\n<ul>\n<li>Now open the file \u2018nano \/etc\/environment\u2019 with a nano text editor by running this command.<\/li>\n<\/ul>\n<pre><code>nano \/etc\/environment<\/code><\/pre>\n<figure><\/figure>\n<ul>\n<li>Now you need to add a line in the opened file in the below manner.\u00a0<\/li>\n<\/ul>\n<pre><code>JAVA_HOME=\"\/your\/installation\/path\/\"<\/code><\/pre>\n<figure><\/figure>\n<ul>\n<li>You have properly mentioned the location of your Java_home environment. That\u2019s it; you have successfully set the location.<\/li>\n<\/ul>\n<h2><span id=\"How_to_Uninstall_Java_on_Ubuntu\">How to Uninstall Java on Ubuntu?<\/span><\/h2>\n<p>Till now you have learned the process to install Java on Ubuntu, now let\u2019s learn how to uninstall. This process starts with the removal of the default version of OpenJDK, for which you have to run the below command \u201csudo apt remove default-jdk.\u201d<\/p>\n<figure><\/figure>\n<p>If there is a need to uninstall a specific version of OpenJDK then simply enter the command \u201csudo apt remove openjdk-#-jdk.\u201d\u00a0<\/p>\n<p>Here, you need to keep in mind that the \u201c#\u201d icon will be replaced with the correct version. At the end, simply press the \u201cy\u201d key to continue the removal process.<\/p>\n<p>Also Read: What is a Server Operating System? Types of Server OS<\/p>\n<h2><span id=\"Conclusion\">Conclusion<\/span><\/h2>\n<p><strong>Installing Java on Ubuntu<\/strong> involves either using the default OpenJDK from the package repository or opting for the official Oracle JDK. By following the provided steps, users can easily set up their preferred Java environment, whether it\u2019s for running Java applications or developing software.\u00a0<\/p>\n<p>Additionally, configuring the default Java version and setting the JAVA_HOME environment variable ensures seamless compatibility and execution across various applications and tools. Lastly, the process of uninstalling Java from Ubuntu, whether it\u2019s the default version or a specific one, is straightforward, allowing users to manage their Java installations efficiently based on their needs.<\/p>\n<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Introduction\u00a0 A high-level language is a significant requirement behind building software and applications. Computers only understand machine language, which is a low-binary language. We can\u2019t develop software and applications through machine language. This is where high-level languages like Java come into the picture.\u00a0 You may question how a computer understands a high-level language. Well, compilers<\/p>\n","protected":false},"author":3,"featured_media":3076,"comment_status":"open","ping_status":"open","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,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[17],"tags":[],"class_list":["post-3265","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dedicated-servers"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/foghosting.com\/blog\/wp-json\/wp\/v2\/posts\/3265","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/foghosting.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/foghosting.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/foghosting.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/foghosting.com\/blog\/wp-json\/wp\/v2\/comments?post=3265"}],"version-history":[{"count":0,"href":"https:\/\/foghosting.com\/blog\/wp-json\/wp\/v2\/posts\/3265\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/foghosting.com\/blog\/wp-json\/wp\/v2\/media\/3076"}],"wp:attachment":[{"href":"https:\/\/foghosting.com\/blog\/wp-json\/wp\/v2\/media?parent=3265"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/foghosting.com\/blog\/wp-json\/wp\/v2\/categories?post=3265"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/foghosting.com\/blog\/wp-json\/wp\/v2\/tags?post=3265"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}