{"id":2595,"date":"2021-12-06T13:19:25","date_gmt":"2021-12-06T11:19:25","guid":{"rendered":"https:\/\/www.scalahosting.com\/kb\/?p=2595"},"modified":"2022-05-19T18:04:27","modified_gmt":"2022-05-19T15:04:27","slug":"how-to-install-java-on-a-vps","status":"publish","type":"post","link":"https:\/\/www.scalahosting.com\/kb\/how-to-install-java-on-a-vps\/","title":{"rendered":"How to Install Java on a VPS?"},"content":{"rendered":"<p><b>Java is a general-purpose programming language<\/b><span style=\"font-weight: 400;\"> that developers widely use for various backend projects. It is well-known for its ability to create apps with different functionalities, especially for Android users.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">This guide aims to help you learn more about the Java basics, its benefits, and how to install it on a virtual private server.<\/span><\/p>\n<p><i><span style=\"font-weight: 400;\">Let&#8217;s jump right in.<\/span><\/i><\/p>\n<h2><b>What is Java?<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">Java was developed and released by <\/span><b>Sun Microsystems<\/b><span style=\"font-weight: 400;\">, a technology giant, which was later acquired by the <\/span><b>Oracle Corporation<\/b><span style=\"font-weight: 400;\">. The programming language proved to be quite versatile for developers, earning it a <\/span><b>3.7% market share<\/b><span style=\"font-weight: 400;\"> today (from all websites with known server-side programming), according to <\/span><a href=\"https:\/\/w3techs.com\/\"><b>W3Techs<\/b><\/a><span style=\"font-weight: 400;\">.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Java is <\/span><b>simple<\/b><span style=\"font-weight: 400;\">, <\/span><b>efficient<\/b><span style=\"font-weight: 400;\">, and <\/span><b>extremely portable<\/b><span style=\"font-weight: 400;\">, meaning the app can run identically on any platform, regardless of its operating system or hardware setup. The programming script also flaunts <\/span><b>advanced security features<\/b><span style=\"font-weight: 400;\">, isolating the environment between the server and an unsecured Java application.<\/span><\/p>\n<p><b>Because of their versatility, Java-written apps have more than a few use cases:<\/b><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Android applications<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Graphic environment (GUI) solutions<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Billing and financial transaction tools<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Complex mathematical calculations<\/span><\/li>\n<\/ul>\n<h2><b>Java Installation Prerequisites<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">Java works with all the major operating systems and their popular distributions. Check out the system requirements for the <\/span><b>different OS types<\/b><span style=\"font-weight: 400;\">:<\/span><\/p>\n<h3><b>Java on Windows<\/b><\/h3>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Windows Server 2008 or 2012 (64 bit)<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">124 MB disk space for JRE plus a few more MB for updates<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><span data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;minimum&quot;}\" data-sheets-userformat=\"{&quot;2&quot;:636,&quot;5&quot;:{&quot;1&quot;:[{&quot;1&quot;:2,&quot;2&quot;:0,&quot;5&quot;:{&quot;1&quot;:2,&quot;2&quot;:0}},{&quot;1&quot;:0,&quot;2&quot;:0,&quot;3&quot;:3},{&quot;1&quot;:1,&quot;2&quot;:0,&quot;4&quot;:1}]},&quot;6&quot;:{&quot;1&quot;:[{&quot;1&quot;:2,&quot;2&quot;:0,&quot;5&quot;:{&quot;1&quot;:2,&quot;2&quot;:0}},{&quot;1&quot;:0,&quot;2&quot;:0,&quot;3&quot;:3},{&quot;1&quot;:1,&quot;2&quot;:0,&quot;4&quot;:1}]},&quot;7&quot;:{&quot;1&quot;:[{&quot;1&quot;:2,&quot;2&quot;:0,&quot;5&quot;:{&quot;1&quot;:2,&quot;2&quot;:0}},{&quot;1&quot;:0,&quot;2&quot;:0,&quot;3&quot;:3},{&quot;1&quot;:1,&quot;2&quot;:0,&quot;4&quot;:1}]},&quot;8&quot;:{&quot;1&quot;:[{&quot;1&quot;:2,&quot;2&quot;:0,&quot;5&quot;:{&quot;1&quot;:2,&quot;2&quot;:0}},{&quot;1&quot;:0,&quot;2&quot;:0,&quot;3&quot;:3},{&quot;1&quot;:1,&quot;2&quot;:0,&quot;4&quot;:1}]},&quot;9&quot;:0,&quot;12&quot;:0}\">Minimum<\/span> processor: Intel 2.23 MHz<\/span><\/li>\n<\/ul>\n<h3><b>Java on Linux<\/b><\/h3>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Suse SLES from 11.x or Ubuntu from 13.x or RHEL from 6.x<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">124 MB disk space for JRE plus a few more MB for updates<\/span><\/li>\n<\/ul>\n<h3><b>Java on macOS<\/b><\/h3>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">macOS X from 10.8<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">124 MB disk space for JRE plus a few more MB for updates<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">As you can see, given you have the right server, there is nothing too demanding in the Java requirements. Still, there is a good reason why it&#8217;s best to host your Java project on a virtual private server.<\/span><\/p>\n<h2><b>Why Java on a VPS?<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">While Java has little to no demands in terms of system resources, the shared hosting environment isn&#8217;t really suited for this popular programming language.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Starting with your server power, <\/span><b>all CPU and RAM on the machine is constantly employed by multiple clients<\/b><span style=\"font-weight: 400;\">, sometimes even 100+ more accounts at once. This means that you can never be sure about the smooth running of your Java project, especially in times of high traffic when you most need your resources.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">There is also the question of your web server. Most hosting providers configure a basic <\/span><a href=\"https:\/\/www.scalahosting.com\/blog\/litespeed-vs-apache\/\"><b>Apache or Litespeed<\/b><\/a><span style=\"font-weight: 400;\">, whereas Java best runs on <\/span><b>Apache Tomcat<\/b><span style=\"font-weight: 400;\">. The latter is custom-tailored to provide an optimized Java environment with all its components implemented.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">One essential element is the <\/span><b>CGI<\/b><span style=\"font-weight: 400;\"> (common gateway interface). This is a <\/span><b>PHP interpreter<\/b><span style=\"font-weight: 400;\"> that is highly optimized for Java and integrated in&#8230;you guessed it&#8230;Tomcat.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">But perhaps the best reason why you should use Java on a <\/span><b>VPS plan <\/b><span style=\"font-weight: 400;\">comes with <\/span><b>server access<\/b><span style=\"font-weight: 400;\">.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">You need<\/span><b> root administrator rights<\/b><span style=\"font-weight: 400;\"> to install Java and for many other actions in the future. For example, should your Java app stop running, you might need to restart the server. Same if you have applied some changes or updates. All that is impossible with shared hosting providers.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">As a matter of fact, most <\/span><a href=\"https:\/\/www.scalahosting.com\/managed-cloud-hosting.html\"><b>managed VPS<\/b><\/a><span style=\"font-weight: 400;\"> hosts won&#8217;t give you full root access as well because that defies the purpose of their management. If that&#8217;s the case &#8211; a <\/span><a href=\"https:\/\/www.scalahosting.com\/cloud-vps-hosting.html\"><b>self-managed virtual server plan<\/b><\/a><span style=\"font-weight: 400;\"> would be your best bet.<\/span><\/p>\n<h2><b>Installing Java on a VPS<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">There are many different Java incarnations that serve very different purposes. For the purpose of this tutorial, we will focus on two of them and their most stable versions &#8211; <\/span><b>OpenJDK 7\/8 and Oracle Java 8<\/b><span style=\"font-weight: 400;\">.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The main difference between the distributions is their business model. While OpenJDK is an <\/span><b>open-source<\/b><span style=\"font-weight: 400;\">, free Java solution, <\/span><b>Oracle JRE\/JDK<\/b><span style=\"font-weight: 400;\"> are <\/span><b>proprietary<\/b><span style=\"font-weight: 400;\"> products that are available at premium prices.<\/span><\/p>\n<h3><b>Installing OpenJDK 7<\/b><\/h3>\n<ol>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Use an <\/span><b>SSH client<\/b><span style=\"font-weight: 400;\"> to log in your server as<\/span><b> root admin<\/b><span style=\"font-weight: 400;\">.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Run <\/b><span style=\"font-weight: 400;\">the installation command:<\/span><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">sudo apt-get install openjdk-7-jre (for Debian\/Ubuntu)<\/span><\/p>\n<p><span style=\"font-weight: 400;\">su -c &#8220;yum install java-1.7.0-openjdk&#8221; (Fedora, RHEL)<\/span><\/p>\n<ol start=\"3\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">If there are any incomplete commands, you can go through them using:<\/span><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">yum-complete-transaction &#8211;cleanup-only<\/span><\/p>\n<h3><b>Installing OpenJDK 8<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">The process for OpenJDK 8 is pretty much the same as with its previous version.<\/span><\/p>\n<ol>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Log into your <\/span><b>SSH client<\/b><span style=\"font-weight: 400;\">.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Depending on your operating system, you can type:<\/span><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">sudo apt-get install openjdk-8-jre (Debian\/Ubuntu)<\/span><\/p>\n<p><span style=\"font-weight: 400;\">su -c &#8220;yum install java-1.8.0-openjdk&#8221; (Fedora, RHEL)<\/span><b><\/b><\/p>\n<h3><b>Installing Oracle Java 8<\/b><\/h3>\n<ol>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Download the <\/span><b>LinuxRPM package<\/b><span style=\"font-weight: 400;\"> from the official website.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Upload it to your VPS server via <\/span><b>control panel\/FTP\/SSH<\/b><span style=\"font-weight: 400;\">.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">To install Oracle Java, you need to be logged into your SSH client as <\/span><b>root<\/b><span style=\"font-weight: 400;\">. Then type:<\/span><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">yum install \/path-to-file\/jdk-[version].rpm<\/span><\/p>\n<p><span style=\"font-weight: 400;\">That&#8217;s all there is to it. You are now ready to install and host Java on your VPS.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Find out <\/span><a href=\"https:\/\/www.scalahosting.com\/kb\/getting-started-with-self-managed-cloud-vps\/\"><b>more self-managed VPS articles<\/b><\/a><span style=\"font-weight: 400;\"> in our <\/span><b>ScalaHosting Knowledge Base<\/b><span style=\"font-weight: 400;\">. <\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Java is a general-purpose programming language that developers widely use for various backend projects. It is well-known for its ability to create apps with different functionalities, especially for Android users.\u00a0 This guide aims to help you learn more about the Java basics, its benefits, and how to install it on a virtual private server. Let&#8217;s [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_seopress_robots_primary_cat":"","_seopress_titles_title":"","_seopress_titles_desc":"","_seopress_robots_index":"","footnotes":""},"categories":[27],"tags":[],"class_list":["post-2595","post","type-post","status-publish","format-standard","hentry","category-vps-hosting"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.scalahosting.com\/kb\/wp-json\/wp\/v2\/posts\/2595","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.scalahosting.com\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.scalahosting.com\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.scalahosting.com\/kb\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.scalahosting.com\/kb\/wp-json\/wp\/v2\/comments?post=2595"}],"version-history":[{"count":4,"href":"https:\/\/www.scalahosting.com\/kb\/wp-json\/wp\/v2\/posts\/2595\/revisions"}],"predecessor-version":[{"id":4565,"href":"https:\/\/www.scalahosting.com\/kb\/wp-json\/wp\/v2\/posts\/2595\/revisions\/4565"}],"wp:attachment":[{"href":"https:\/\/www.scalahosting.com\/kb\/wp-json\/wp\/v2\/media?parent=2595"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.scalahosting.com\/kb\/wp-json\/wp\/v2\/categories?post=2595"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.scalahosting.com\/kb\/wp-json\/wp\/v2\/tags?post=2595"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}