{"id":10150,"date":"2026-07-19T12:35:49","date_gmt":"2026-07-19T07:05:49","guid":{"rendered":"https:\/\/xenaxcloud.com\/blog\/?p=10150"},"modified":"2026-11-06T16:04:21","modified_gmt":"2026-11-06T10:34:21","slug":"install-java-in-ubuntu","status":"publish","type":"post","link":"https:\/\/xenaxcloud.com\/blog\/install-java-in-ubuntu\/","title":{"rendered":"Install Java in Ubuntu: Complete Step-by-Step Guide"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">To install java ubuntu, use the APT package manager to install OpenJDK, the open-source implementation of the Java Platform. By running <code>sudo apt update<\/code> followed by <code>sudo apt install default-jdk<\/code>, you can quickly set up the Java Runtime Environment (JRE) and Development Kit (JDK) on Ubuntu 24.04 or 22.04.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This guide provides step-by-step instructions for the command line, explains how to manage multiple Java versions, and helps you determine the server resources needed for your specific Java application.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Check Prerequisites Before You Install Java on Ubuntu<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before starting the installation, you must ensure your system package index is current and your server architecture is compatible with the JDK version you intend to use. Verifying these prerequisites prevents dependency errors and installation failures during the setup process.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Picture a Jaipur fintech startup setting up a new production server for daily transaction processing. To ensure the environment is stable, their engineers follow a pre-installation checklist to avoid version mismatches that could crash their payment gateway.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Updating your package repository<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The first step is to synchronize your local package index with the remote Ubuntu repositories. This ensures you download the latest security patches and the most recent stable build of OpenJDK.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Run the following command in your terminal:<\/p>\n\n\n\n<figure class=\"xb-codebox\" data-xb-codebox data-xb-lang=\"Shell\"><figcaption class=\"xb-codebox__bar\"><span class=\"xb-codebox__lang\">Shell<\/span><button type=\"button\" class=\"xb-codebox__copy\" data-xb-copy aria-label=\"Copy Shell code to clipboard\"><svg class=\"xb-codebox__icon\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\"><rect x=\"9\" y=\"9\" width=\"12\" height=\"12\" rx=\"2\"><\/rect><path d=\"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1\"><\/path><\/svg><svg class=\"xb-codebox__icon xb-codebox__icon--done\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\"><path d=\"M20 6 9 17l-5-5\"><\/path><\/svg><span class=\"xb-codebox__copytext\">Copy<\/span><\/button><\/figcaption><pre class=\"wp-block-code xb-codebox__pre\"><code>sudo apt update<\/code><\/pre><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The expected output will show the system hitting the official Ubuntu archives. If you see &#8220;Reading package lists&#8230; Done&#8221;, your server is ready to fetch the Java binaries.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Checking Ubuntu version and architecture<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">You need to know your OS version and CPU architecture to ensure the JDK package is compatible. Most modern servers use x86_64 (amd64), but some ARM-based instances require different binaries.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Use these commands to verify your environment:<\/p>\n\n\n\n<figure class=\"xb-codebox\" data-xb-codebox data-xb-lang=\"Shell\"><figcaption class=\"xb-codebox__bar\"><span class=\"xb-codebox__lang\">Shell<\/span><button type=\"button\" class=\"xb-codebox__copy\" data-xb-copy aria-label=\"Copy Shell code to clipboard\"><svg class=\"xb-codebox__icon\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\"><rect x=\"9\" y=\"9\" width=\"12\" height=\"12\" rx=\"2\"><\/rect><path d=\"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1\"><\/path><\/svg><svg class=\"xb-codebox__icon xb-codebox__icon--done\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\"><path d=\"M20 6 9 17l-5-5\"><\/path><\/svg><span class=\"xb-codebox__copytext\">Copy<\/span><\/button><\/figcaption><pre class=\"wp-block-code xb-codebox__pre\"><code>lsb_release -a\nuname -m<\/code><\/pre><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>lsb_release<\/code> command confirms if you are on Ubuntu 24.04 or 22.04, while <code>uname -m<\/code> identifies the architecture. For example, an output of <code>x86_64<\/code> indicates a 64-bit Intel or AMD processor.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To ensure your environment is production-ready, we recommend using a <a href=\"https:\/\/xenaxcloud.com\/blog\/vps-linux-ubuntu\/\">VPS with Linux Ubuntu<\/a> that provides dedicated resources to handle the JVM&#8217;s memory demands.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/xenaxcloud.com\/blog\/wp-content\/uploads\/2026\/11\/install-java-in-ubuntu-guide.webp\" alt=\"Table comparing Java LTS versions for Ubuntu server deployments\" class=\"wp-image-12006\" width=\"1200\" height=\"675\" srcset=\"https:\/\/xenaxcloud.com\/blog\/wp-content\/uploads\/2026\/11\/install-java-in-ubuntu-guide.webp 1200w, https:\/\/xenaxcloud.com\/blog\/wp-content\/uploads\/2026\/11\/install-java-in-ubuntu-guide-300x169.webp 300w, https:\/\/xenaxcloud.com\/blog\/wp-content\/uploads\/2026\/11\/install-java-in-ubuntu-guide-1024x576.webp 1024w, https:\/\/xenaxcloud.com\/blog\/wp-content\/uploads\/2026\/11\/install-java-in-ubuntu-guide-768x432.webp 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><figcaption class=\"wp-element-caption\">Choosing the correct Long-Term Support release for production stability<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">How to Install OpenJDK on Ubuntu Using the Terminal<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">You can install OpenJDK on Ubuntu by using the APT package manager to fetch the official open-source binaries from the Ubuntu repositories. This method is the most secure way to manage your Java installation because it ensures all files are digitally signed and verified by the OS maintainers.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Running the default JDK installation<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">If you want the standard version of Java that is most compatible with the current Ubuntu release, you should install the default JDK package. This command automatically selects the most stable version recommended for your specific OS version.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Run this command to start the process:<\/p>\n\n\n\n<figure class=\"xb-codebox\" data-xb-codebox data-xb-lang=\"Shell\"><figcaption class=\"xb-codebox__bar\"><span class=\"xb-codebox__lang\">Shell<\/span><button type=\"button\" class=\"xb-codebox__copy\" data-xb-copy aria-label=\"Copy Shell code to clipboard\"><svg class=\"xb-codebox__icon\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\"><rect x=\"9\" y=\"9\" width=\"12\" height=\"12\" rx=\"2\"><\/rect><path d=\"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1\"><\/path><\/svg><svg class=\"xb-codebox__icon xb-codebox__icon--done\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\"><path d=\"M20 6 9 17l-5-5\"><\/path><\/svg><span class=\"xb-codebox__copytext\">Copy<\/span><\/button><\/figcaption><pre class=\"wp-block-code xb-codebox__pre\"><code>sudo apt install default-jdk -y<\/code><\/pre><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>-y<\/code> flag automatically answers &#8220;yes&#8221; to the prompt, which is helpful when you are automating server setups via SSH. Once the process finishes, the terminal will return to the command prompt, indicating that the binaries are ready for use.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Installing specific Long-Term Support versions<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Many developers prefer to install a specific Long-Term Support (LTS) version to ensure application stability over several years. For example, a developer might specifically need OpenJDK 17 or OpenJDK 21 for a project.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To install a specific version, use the following commands:<\/p>\n\n\n\n<figure class=\"xb-codebox\" data-xb-codebox data-xb-lang=\"Shell\"><figcaption class=\"xb-codebox__bar\"><span class=\"xb-codebox__lang\">Shell<\/span><button type=\"button\" class=\"xb-codebox__copy\" data-xb-copy aria-label=\"Copy Shell code to clipboard\"><svg class=\"xb-codebox__icon\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\"><rect x=\"9\" y=\"9\" width=\"12\" height=\"12\" rx=\"2\"><\/rect><path d=\"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1\"><\/path><\/svg><svg class=\"xb-codebox__icon xb-codebox__icon--done\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\"><path d=\"M20 6 9 17l-5-5\"><\/path><\/svg><span class=\"xb-codebox__copytext\">Copy<\/span><\/button><\/figcaption><pre class=\"wp-block-code xb-codebox__pre\"><code>sudo apt install openjdk-17-jdk -y\n\nsudo apt install openjdk-21-jdk -y<\/code><\/pre><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">If you are managing a high-performance environment, such as a <a href=\"https:\/\/xenaxcloud.com\/dedicated-server\/\">Dedicated Server<\/a> for heavy computation, you might want to verify which version is currently being pulled from the repositories. You can check the available versions in the Ubuntu archive by running <code>apt cache search openjdk<\/code>, which lists every available JDK package compatible with your system.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Verify Your Java Installation and Compiler<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">You can verify your Java installation by running the <code>java -version<\/code> and <code>javac -version<\/code> commands in the terminal to confirm the binaries are active and the system path is correctly configured. This ensures that both the runtime environment and the compiler are ready to execute and build Java applications.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Checking the Java runtime version<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The Java Runtime Environment (JRE) is the part of the Java platform that allows you to run compiled Java code. To check if the runtime is active, run:<\/p>\n\n\n\n<figure class=\"xb-codebox\" data-xb-codebox data-xb-lang=\"Shell\"><figcaption class=\"xb-codebox__bar\"><span class=\"xb-codebox__lang\">Shell<\/span><button type=\"button\" class=\"xb-codebox__copy\" data-xb-copy aria-label=\"Copy Shell code to clipboard\"><svg class=\"xb-codebox__icon\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\"><rect x=\"9\" y=\"9\" width=\"12\" height=\"12\" rx=\"2\"><\/rect><path d=\"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1\"><\/path><\/svg><svg class=\"xb-codebox__icon xb-codebox__icon--done\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\"><path d=\"M20 6 9 17l-5-5\"><\/path><\/svg><span class=\"xb-codebox__copytext\">Copy<\/span><\/button><\/figcaption><pre class=\"wp-block-code xb-codebox__pre\"><code>java -version<\/code><\/pre><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The expected output will look like this:<\/p>\n\n\n\n<figure class=\"xb-codebox\" data-xb-codebox data-xb-lang=\"Code\"><figcaption class=\"xb-codebox__bar\"><span class=\"xb-codebox__lang\">Code<\/span><button type=\"button\" class=\"xb-codebox__copy\" data-xb-copy aria-label=\"Copy code to clipboard\"><svg class=\"xb-codebox__icon\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\"><rect x=\"9\" y=\"9\" width=\"12\" height=\"12\" rx=\"2\"><\/rect><path d=\"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1\"><\/path><\/svg><svg class=\"xb-codebox__icon xb-codebox__icon--done\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\"><path d=\"M20 6 9 17l-5-5\"><\/path><\/svg><span class=\"xb-codebox__copytext\">Copy<\/span><\/button><\/figcaption><pre class=\"wp-block-code xb-codebox__pre\"><code>openjdk version \"17.0.x\" \nOpenJDK Runtime Environment (build 17.0.x+x) \nOpenJDK 64-Bit Server VM own 17.0.x+x<\/code><\/pre><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">If you see this output, the Java runtime is active. If you get a &#8220;command not found&#8221; error, the installation failed or the system path is not updated.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Verifying the javac compiler<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The Java Compiler (<code>javac<\/code>) is the tool that converts human-readable <code>.java<\/code> files into bytecode. This is part of the the JDK (Java Development Kit) and is essential for developers.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Run this command to verify the compiler:<\/p>\n\n\n\n<figure class=\"xb-codebox\" data-xb-codebox data-xb-lang=\"Shell\"><figcaption class=\"xb-codebox__bar\"><span class=\"xb-codebox__lang\">Shell<\/span><button type=\"button\" class=\"xb-codebox__copy\" data-xb-copy aria-label=\"Copy Shell code to clipboard\"><svg class=\"xb-codebox__icon\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\"><rect x=\"9\" y=\"9\" width=\"12\" height=\"12\" rx=\"2\"><\/rect><path d=\"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1\"><\/path><\/svg><svg class=\"xb-codebox__icon xb-codebox__icon--done\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\"><path d=\"M20 6 9 17l-5-5\"><\/path><\/svg><span class=\"xb-codebox__copytext\">Copy<\/span><\/button><\/figcaption><pre class=\"wp-block-code xb-codebox__pre\"><code>javac -version<\/code><\/pre><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The expected output should be a simple version string, such as <code>javac 17.0.x<\/code>. This is a lenguaje-specific verification that confirms you can now compile source code.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To ensure your server can handle the JVM&#8217;s memory overhead, we recommend checking your available system RAM. You can run <code>free -h<\/code> to see if you have at least 2 GB of RAM for basic apps, or 8 GB for production workloads. For a Jaipur fintech startup deploying a Spring Boot microservice, 8 GB of RAM is necessary to handle concurrent API requests and memory-intensive garbage collection routines.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To learn more about managing your runtime environment, you can read our guide on how to <a href=\"https:\/\/xenaxcloud.com\/blog\/install-java-runtime-ubuntu\/\">install java runtime ubuntu<\/a>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/xenaxcloud.com\/blog\/wp-content\/uploads\/2026\/11\/install-java-in-ubuntu-xenax-plans.webp\" alt=\"Xenax Cloud VPS hosting product page showing available plans\" class=\"wp-image-12007\" width=\"1200\" height=\"675\" srcset=\"https:\/\/xenaxcloud.com\/blog\/wp-content\/uploads\/2026\/11\/install-java-in-ubuntu-xenax-plans-768x432.webp 768w, https:\/\/xenaxcloud.com\/blog\/wp-content\/uploads\/2026\/11\/install-java-in-ubuntu-xenax-plans-1280x720.webp 1280w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><figcaption class=\"wp-element-caption\">Explore our high-performance KVM VPS plans for hosting production Java applications. Screenshot taken 6 November 2026; prices are hidden, see the plan box for today&#8217;s price.<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><aside class=\"xseo-plan xseo-plan--vps\" data-xseo-cta=\"vps\" data-xseo-pos=\"inline\"><div class=\"xseo-plan__head\"><div><span class=\"xseo-plan__kicker\">Xenax Cloud<\/span><h3 class=\"xseo-plan__name\">VPS Hosting<\/h3><p class=\"xseo-plan__tagline\">Power meets freedom.<\/p><\/div><span class=\"xseo-plan__badge\">FAST<\/span><\/div><p class=\"xseo-plan__desc\">Dedicated resources, full root access, NVMe\/SSD storage and weekly free snapshots.<\/p><div class=\"xseo-plan__body\"><ul class=\"xseo-plan__features\"><li><svg viewBox=\"0 0 20 20\" aria-hidden=\"true\"><circle cx=\"10\" cy=\"10\" r=\"9\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\"\/><path d=\"M6 10.5l2.5 2.5L14 7.5\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\/><\/svg>4 GB RAM \u00b7 2 vCPU<\/li><li><svg viewBox=\"0 0 20 20\" aria-hidden=\"true\"><circle cx=\"10\" cy=\"10\" r=\"9\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\"\/><path d=\"M6 10.5l2.5 2.5L14 7.5\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\/><\/svg>40 GB SSD storage<\/li><li><svg viewBox=\"0 0 20 20\" aria-hidden=\"true\"><circle cx=\"10\" cy=\"10\" r=\"9\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\"\/><path d=\"M6 10.5l2.5 2.5L14 7.5\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\/><\/svg>2 TB bandwidth<\/li><li><svg viewBox=\"0 0 20 20\" aria-hidden=\"true\"><circle cx=\"10\" cy=\"10\" r=\"9\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\"\/><path d=\"M6 10.5l2.5 2.5L14 7.5\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\/><\/svg>1 IPv4 + IPv6<\/li><\/ul><div class=\"xseo-plan__price\"><span class=\"xseo-plan__from\">from<\/span><span class=\"xseo-plan__amount\" data-inr=\"599\">\u20b9599<\/span><span class=\"xseo-plan__period\">\/mo<\/span><\/div><\/div><a class=\"xseo-plan__btn\" href=\"https:\/\/xenaxcloud.com\/vps-server\/?utm_source=blog&#038;utm_medium=cta&#038;utm_campaign=install-java-in-ubuntu&#038;utm_content=vps-inline\" target=\"_blank\" rel=\"noopener\">View plans <span aria-hidden=\"true\">\u2192<\/span><\/a><p class=\"xseo-plan__trust\">24\u00d77 support \u00b7 WhatsApp \u00b7 Indian data centre \u00b7 GST-registered<\/p><\/aside><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><aside class=\"xseo-rev\" aria-label=\"Customer reviews\"><p class=\"xseo-rev__head\">What customers wrote about Xenax Cloud<\/p><div class=\"xseo-rev__grid\"><figure class=\"xseo-rev__card\"><blockquote><p class=\"xseo-rev__t\">Their RDP services are impressive<\/p><p>Their RDP services are impressive, and their support is excellent. Even though I&#039;m from Pakistan and they&#039;re Indian, they have cooperated with me far better than many Pakistani providers.<\/p><\/blockquote><figcaption>Plee Dex \u00b7 Pakistan \u00b7 17 Oct 2026<\/figcaption><\/figure><figure class=\"xseo-rev__card\"><blockquote><p class=\"xseo-rev__t\">Was paying 6k for aws just for ec2<\/p><p>Was paying 6k for aws just for ec2 and i didn&#039;t required any other services so thought of exploring other server provider in specifically in india ... his support is extremely professional and kind and after comparing prices from aws its way cheap im saving aroung 60-70% approx<\/p><\/blockquote><figcaption>Nitish Gupta \u00b7 India \u00b7 9 Aug 2025<\/figcaption><\/figure><\/div><p class=\"xseo-rev__src\">Reviews quoted as written on <a target=\"_blank\" href=\"https:\/\/www.trustpilot.com\/review\/xenaxcloud.com\" rel=\"noopener nofollow\">Trustpilot<\/a>, checked 6 November 2026. <a target=\"_blank\" href=\"https:\/\/www.trustpilot.com\/review\/xenaxcloud.com\" rel=\"noopener nofollow\">Read all reviews<\/a>.<\/p><\/aside><style>.xseo-rev{margin:2rem 0;padding:1.25rem;border-radius:14px;background:#f4f7ff;border:1px solid #dfe6fb}.xseo-rev__head{font-weight:700;margin:0 0 .75rem;color:#0e123e}.xseo-rev__grid{display:grid;gap:.9rem;grid-template-columns:repeat(auto-fit,minmax(240px,1fr))}.xseo-rev__card{margin:0;background:#fff;border-radius:12px;padding:1rem;border:1px solid #e3e8f7}.xseo-rev__card blockquote,.xseo-rev__card blockquote p{margin:0;border:0!important;padding:0!important;font-style:normal;background:transparent!important;box-shadow:none!important}.xseo-rev__card blockquote::before,.xseo-rev__card blockquote::after{display:none!important}.xseo-rev__card blockquote p{margin:0 0 .5rem;font-size:.95rem;line-height:1.55}.xseo-rev__t{font-weight:700;color:#0e123e}.xseo-rev__card figcaption{font-size:.8rem;color:#5b6687}.xseo-rev__src{font-size:.78rem;color:#5b6687;margin:.75rem 0 0}<\/style><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Install Multiple Java Versions on Ubuntu<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">You can install multiple versions of Java on Ubuntu by installing different OpenJDK packages side-by-side, as the system stores them in separate directories. This allows you to maintain legacy support for older applications while developing new features on the latest LTS release.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Installing OpenJDK 11 and OpenJDK 21<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">To support a range of application requirements, you can install several versions of the Java Development Kit (JDK) using the <code>apt<\/code> package manager. For example, if you need to maintain an older enterprise app on Java 11 and a modern microservice on Java 21, run these commands:<\/p>\n\n\n\n<figure class=\"xb-codebox\" data-xb-codebox data-xb-lang=\"Shell\"><figcaption class=\"xb-codebox__bar\"><span class=\"xb-codebox__lang\">Shell<\/span><button type=\"button\" class=\"xb-codebox__copy\" data-xb-copy aria-label=\"Copy Shell code to clipboard\"><svg class=\"xb-codebox__icon\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\"><rect x=\"9\" y=\"9\" width=\"12\" height=\"12\" rx=\"2\"><\/rect><path d=\"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1\"><\/path><\/svg><svg class=\"xb-codebox__icon xb-codebox__icon--done\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\"><path d=\"M20 6 9 17l-5-5\"><\/path><\/svg><span class=\"xb-codebox__copytext\">Copy<\/span><\/button><\/figcaption><pre class=\"wp-block-code xb-codebox__pre\"><code>sudo apt install openjdk-11-jdk -y\nsudo apt install openjdk-21-jdk -y<\/code><\/pre><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Once these commands complete, Ubuntu stores the binaries in <code>\/usr\/lib\/jvm\/<\/code>. You can list all installed Java environments by running <code>ls \/usr\/lib\/jvm\/<\/code>, which will show directories for each version you have added.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Managing side-by-side Java packages<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Managing multiple versions requires understanding how the system handles the default path. When you install multiple JDKs, Ubuntu uses a system called &#8220;alternatives&#8221; to link the generic <code>java<\/code> command to a specific version.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To ensure your server has enough overhead for multiple JVMs, consider the memory footprint. A standard JVM instance typically requires a minimum heap size. If you run three different Java versions for three separate apps, your RAM calculation looks like this:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Application<\/th><th>Java Version<\/th><th>Min Heap (Xms)<\/th><th>OS Overhead<\/th><th>Total RAM Needed<\/th><\/tr><\/thead><tbody><tr><td>Legacy API<\/td><td>Java 11<\/td><td>1 GB<\/td><td>512 MB<\/td><td>1.5 GB<\/td><\/tr><tr><td>Modern App<\/td><td>Java 21<\/td><td>2 GB<\/td><td>512 MB<\/td><td>2.5 GB<\/td><\/tr><tr><td>Build Tool<\/td><td>Java 17<\/td><td>1 GB<\/td><td>512 MB<\/td><td>1.5 GB<\/td><\/tr><tr><td><strong>Total<\/strong><\/td><td><\/td><td><\/td><td><\/td><td><strong>5.5 GB<\/strong><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Because of this cumulative memory usage, a <a href=\"https:\/\/xenaxcloud.com\/vps-server\/\">KVM VPS<\/a> with at least 8 GB of RAM is recommended for developers running multiple environments.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Switch Between Multiple Java Versions<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">You can switch between different installed Java versions on Ubuntu by using the <code>update-alternatives<\/code> utility. This tool allows you to change which version the system uses as the default whenever you run the <code>java<\/code> command.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Configuring default java with update-alternatives<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>update-alternatives<\/code> system manages multiple versions of the same software by creating symbolic links to the actual binaries. To begin the switching process, you must run the configuration command with administrative privileges.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Run this command to manage the Java runtime:<\/p>\n\n\n\n<figure class=\"xb-codebox\" data-xb-codebox data-xb-lang=\"Shell\"><figcaption class=\"xb-codebox__bar\"><span class=\"xb-codebox__lang\">Shell<\/span><button type=\"button\" class=\"xb-codebox__copy\" data-xb-copy aria-label=\"Copy Shell code to clipboard\"><svg class=\"xb-codebox__icon\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\"><rect x=\"9\" y=\"9\" width=\"12\" height=\"12\" rx=\"2\"><\/rect><path d=\"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1\"><\/path><\/svg><svg class=\"xb-codebox__icon xb-codebox__icon--done\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\"><path d=\"M20 6 9 17l-5-5\"><\/path><\/svg><span class=\"xb-codebox__copytext\">Copy<\/span><\/button><\/figcaption><pre class=\"wp-block-code xb-codebox__pre\"><code>sudo update-alternatives --config java<\/code><\/pre><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">If you also need to switch the version of the Java compiler to match your runtime, run:<\/p>\n\n\n\n<figure class=\"xb-codebox\" data-xb-codebox data-xb-lang=\"Shell\"><figcaption class=\"xb-codebox__bar\"><span class=\"xb-codebox__lang\">Shell<\/span><button type=\"button\" class=\"xb-codebox__copy\" data-xb-copy aria-label=\"Copy Shell code to clipboard\"><svg class=\"xb-codebox__icon\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\"><rect x=\"9\" y=\"9\" width=\"12\" height=\"12\" rx=\"2\"><\/rect><path d=\"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1\"><\/path><\/svg><svg class=\"xb-codebox__icon xb-codebox__icon--done\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\"><path d=\"M20 6 9 17l-5-5\"><\/path><\/svg><span class=\"xb-codebox__copytext\">Copy<\/span><\/button><\/figcaption><pre class=\"wp-block-code xb-codebox__pre\"><code>sudo update-alternatives --config javac<\/code><\/pre><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Selecting the active runtime number<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">After running the command, Ubuntu will display a list of all installed Java environments in your terminal. You will see a table similar to the one below:<\/p>\n\n\n\n<figure class=\"xb-codebox\" data-xb-codebox data-xb-lang=\"SQL\"><figcaption class=\"xb-codebox__bar\"><span class=\"xb-codebox__lang\">SQL<\/span><button type=\"button\" class=\"xb-codebox__copy\" data-xb-copy aria-label=\"Copy SQL code to clipboard\"><svg class=\"xb-codebox__icon\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\"><rect x=\"9\" y=\"9\" width=\"12\" height=\"12\" rx=\"2\"><\/rect><path d=\"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1\"><\/path><\/svg><svg class=\"xb-codebox__icon xb-codebox__icon--done\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\"><path d=\"M20 6 9 17l-5-5\"><\/path><\/svg><span class=\"xb-codebox__copytext\">Copy<\/span><\/button><\/figcaption><pre class=\"wp-block-code xb-codebox__pre\"><code>There are 3 choices for the alternative java (providing \/usr\/bin\/java).\n\n  Selection    Path                                            Priority   Status\n------------------------------------------------------------ Alternatve\n* 0            \/usr\/lib\/jvm\/java-21-openjdk-amd64\/bin\/java      2111      auto mode\n  1            \/usr\/lib\/jvm\/java-11-openjdk-amd64\/bin\/java      1111      manual mode\n  2            \/usr\/lib\/jvm\/java-17-openjdk-amd64\/bin\/java      1711      manual mode\n  3            \/usr\/lib\/jvm\/java-21-openjdk-amd64\/bin\/java      2111      manual mode\n\nPress &lt;enter&gt; to keep the current choice[*], or type selection number: <\/code><\/pre><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">To change your version, type the number corresponding to your desired Java release (for example, <code>2<\/code> for Java 17) and press Enter. The asterisk <code>*<\/code> indicates your current active version.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Before switching, use this checklist to ensure a smooth transition:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Run <code>java -version<\/code> to confirm the change took effect immediately.<\/li><li>Check <code>javac -version<\/code> to ensure your compiler matches your runtime.<\/li><li>Verify that your application&#8217;s environment variables, such as <code>JAVA_HOME<\/code>, point to the new path in <code>\/usr\/lib\/jvm\/<\/code>.<\/li><li>Restart any running services, such as Tomcat or Jenkins, to ensure they pick up the new version.<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Which Server Resources Do Java Applications Need?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Java applications require significant RAM and CPU to manage the Java Virtual Machine (JVM) and handle garbage collection efficiently. Selecting a server with sufficient resources prevents &#8220;Out of Memory&#8221; errors and ensures your applications remain responsive during traffic spikes.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Calculating RAM for Java heap sizes<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The most critical resource for Java is memory, specifically the heap space where objects reside. Unlike simple web scripts, Java applications often reserve a large block of RAM upfront.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Consider a Jaipur fintech startup deploying a Spring Boot microservice on Ubuntu 24.04. To handle concurrent API requests and memory-intensive garbage collection routines, they need at least 8 GB of RAM. If they only allocate 2 GB, the JVM may trigger frequent &#8220;Stop-the-World&#8221; garbage collection cycles, causing noticeable latency for their users.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When planning your deployment, use this rule of thumb for memory allocation:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Component<\/th><th>Resource Type<\/th><th>Recommended Allocation<\/th><\/tr><\/thead><tbody><tr><td>JVM Heap (Xmx)<\/td><td>RAM<\/td><td>50% to 70% of total system RAM<\/td><\/tr><tr><td>OS &amp; Background Services<\/td><td>RAM<\/td><td>1 GB to 2 GB<\/td><\/tr><tr><td>Buffer\/Cache<\/td><td>RAM<\/td><td>Remaining available memory<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Selecting CPU cores for compilation workloads<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">CPU cores determine how quickly your server can compile code and process complex logic. While a running application might only need 2 vCPUs, tasks like running a Jenkins build or compiling large Maven projects are highly parallelizable and benefit from more cores.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you are running heavy CI\/CD pipelines alongside your production apps, you should look for higher core counts. For instance, moving from a 2 vCPU setup to a 4 vCPU setup can significantly reduce the time spent in the &#8220;Building&#8221; stage of your deployment.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To run your Java workloads with low latency and dedicated resources, deploy a Speed KVM VPS 2 from Xenax Cloud.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><div class=\"xseo-pt\"><table><thead><tr><th>Plan<\/th><th>vCPU<\/th><th>RAM<\/th><th>SSD storage<\/th><th>Bandwidth<\/th><th>Price<\/th><\/tr><\/thead><tbody><tr><td>Speed KVM VPS 1<\/td><td>2<\/td><td>4 GB<\/td><td>40 GB<\/td><td>2 TB<\/td><td class=\"xseo-pt__price\"><span class=\"xseo-plan__amount xseo-pt__amt\" data-inr=\"599\">\u20b9599<\/span><span class=\"xseo-pt__per\">\/mo<\/span><\/td><\/tr><tr><td>Speed KVM VPS 2<\/td><td>4<\/td><td>8 GB<\/td><td>50 GB<\/td><td>2 TB<\/td><td class=\"xseo-pt__price\"><span class=\"xseo-plan__amount xseo-pt__amt\" data-inr=\"799\">\u20b9799<\/span><span class=\"xseo-pt__per\">\/mo<\/span><\/td><\/tr><tr><td>Speed KVM VPS 3<\/td><td>8<\/td><td>16 GB<\/td><td>70 GB<\/td><td>4 TB<\/td><td class=\"xseo-pt__price\"><span class=\"xseo-plan__amount xseo-pt__amt\" data-inr=\"1399\">\u20b91,399<\/span><span class=\"xseo-pt__per\">\/mo<\/span><\/td><\/tr><tr><td>Speed KVM VPS 4<\/td><td>12<\/td><td>24 GB<\/td><td>80 GB<\/td><td>6 TB<\/td><td class=\"xseo-pt__price\"><span class=\"xseo-plan__amount xseo-pt__amt\" data-inr=\"1799\">\u20b91,799<\/span><span class=\"xseo-pt__per\">\/mo<\/span><\/td><\/tr><tr><td>Speed KVM VPS 5<\/td><td>16<\/td><td>32 GB<\/td><td>100 GB<\/td><td>8 TB<\/td><td class=\"xseo-pt__price\"><span class=\"xseo-plan__amount xseo-pt__amt\" data-inr=\"2399\">\u20b92,399<\/span><span class=\"xseo-pt__per\">\/mo<\/span><\/td><\/tr><tr><td>Speed KVM VPS 6<\/td><td>20<\/td><td>40 GB<\/td><td>120 GB<\/td><td>10 TB<\/td><td class=\"xseo-pt__price\"><span class=\"xseo-plan__amount xseo-pt__amt\" data-inr=\"2999\">\u20b92,999<\/span><span class=\"xseo-pt__per\">\/mo<\/span><\/td><\/tr><tr><td>Speed KVM VPS 7<\/td><td>24<\/td><td>48 GB<\/td><td>150 GB<\/td><td>10 TB<\/td><td class=\"xseo-pt__price\"><span class=\"xseo-plan__amount xseo-pt__amt\" data-inr=\"3499\">\u20b93,499<\/span><span class=\"xseo-pt__per\">\/mo<\/span><\/td><\/tr><tr><td>Speed KVM VPS 8<\/td><td>32<\/td><td>64 GB<\/td><td>200 GB<\/td><td>10 TB<\/td><td class=\"xseo-pt__price\"><span class=\"xseo-plan__amount xseo-pt__amt\" data-inr=\"4599\">\u20b94,599<\/span><span class=\"xseo-pt__per\">\/mo<\/span><\/td><\/tr><\/tbody><\/table><p class=\"xseo-pt__note\">Every Speed VPS: KVM, full root, 500 Mbps port, weekly backup included, Indian data centre. Monthly, billed in INR. cPanel licence not included.<\/p><p class=\"xseo-pt__cta\"><a class=\"xseo-pt__btn\" href=\"https:\/\/xenaxcloud.com\/speed-vps\/?utm_source=blog&#038;utm_medium=price-table&#038;utm_campaign=install-java-in-ubuntu\">See Speed VPS plans \u2192<\/a><\/p><\/div><style>.xseo-pt{margin:24px 0;overflow-x:auto}.xseo-pt table{width:100%;border-collapse:collapse;font-size:15px;min-width:560px}.xseo-pt th,.xseo-pt td{border:1px solid #e4e6ea;padding:10px 12px;text-align:left;vertical-align:top}.xseo-pt th{background:#f4f6fa;font-weight:600;color:#0f1115}.xseo-pt__price{white-space:nowrap}.xseo-pt .xseo-pt__amt{font:700 17px\/1.2 Outfit,Inter,sans-serif;color:#0f1115;letter-spacing:0}.xseo-pt__per{color:#64748b;font-size:13px;margin-left:2px}.xseo-pt .xseo-plan__inr{display:block;font-size:11px}.xseo-pt__note{font-size:13px;color:#64748b;margin:8px 0 0}.xseo-pt__cta{margin:14px 0 0}.xseo-pt .xseo-pt__btn{display:inline-block;background:#2563eb;color:#fff;font-weight:600;font-size:15px;padding:11px 20px;border-radius:8px;text-decoration:none}.xseo-pt .xseo-pt__btn:hover{background:#1d4ed8;color:#fff}<\/style><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><aside class=\"xseo-plan xseo-plan--dedicated\" data-xseo-cta=\"dedicated\" data-xseo-pos=\"inline\"><div class=\"xseo-plan__head\"><div><span class=\"xseo-plan__kicker\">Xenax Cloud<\/span><h3 class=\"xseo-plan__name\">Dedicated Server<\/h3><p class=\"xseo-plan__tagline\">Raw power. No sharing.<\/p><\/div><span class=\"xseo-plan__badge\">ENTERPRISE<\/span><\/div><p class=\"xseo-plan__desc\">Bare-metal Xeon and EPYC servers with full root and IPMI, in a Tier-III data centre in India.<\/p><div class=\"xseo-plan__body\"><ul class=\"xseo-plan__features\"><li><svg viewBox=\"0 0 20 20\" aria-hidden=\"true\"><circle cx=\"10\" cy=\"10\" r=\"9\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\"\/><path d=\"M6 10.5l2.5 2.5L14 7.5\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\/><\/svg>Xeon E-2314 \u00b7 4 cores<\/li><li><svg viewBox=\"0 0 20 20\" aria-hidden=\"true\"><circle cx=\"10\" cy=\"10\" r=\"9\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\"\/><path d=\"M6 10.5l2.5 2.5L14 7.5\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\/><\/svg>16 GB DDR4 ECC RAM<\/li><li><svg viewBox=\"0 0 20 20\" aria-hidden=\"true\"><circle cx=\"10\" cy=\"10\" r=\"9\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\"\/><path d=\"M6 10.5l2.5 2.5L14 7.5\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\/><\/svg>480 GB NVMe<\/li><li><svg viewBox=\"0 0 20 20\" aria-hidden=\"true\"><circle cx=\"10\" cy=\"10\" r=\"9\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\"\/><path d=\"M6 10.5l2.5 2.5L14 7.5\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\/><\/svg>10 TB on a 1 Gbps port<\/li><li><svg viewBox=\"0 0 20 20\" aria-hidden=\"true\"><circle cx=\"10\" cy=\"10\" r=\"9\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\"\/><path d=\"M6 10.5l2.5 2.5L14 7.5\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\/><\/svg>IPMI included<\/li><\/ul><div class=\"xseo-plan__price\"><span class=\"xseo-plan__from\">from<\/span><span class=\"xseo-plan__amount\" data-inr=\"7999\">\u20b97999<\/span><span class=\"xseo-plan__period\">\/mo<\/span><\/div><\/div><a class=\"xseo-plan__btn\" href=\"https:\/\/xenaxcloud.com\/dedicated-server\/?utm_source=blog&#038;utm_medium=cta&#038;utm_campaign=install-java-in-ubuntu&#038;utm_content=dedicated-inline\" target=\"_blank\" rel=\"noopener\">View plans <span aria-hidden=\"true\">\u2192<\/span><\/a><p class=\"xseo-plan__trust\">24\u00d77 support \u00b7 WhatsApp \u00b7 Indian data centre \u00b7 GST-registered<\/p><\/aside><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Install Java Ubuntu: FAQs<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">How do I install Java on Ubuntu using the command line?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">You can install Java by using the apt package manager with the command <code>sudo apt install openjdk-jdk<\/code>. For a specific version, such as OpenJDK 17, use <code>sudo apt install openjdk-17-jdk -y<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Which Java version should I install on Ubuntu for production?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">For production environments, we recommend installing a Long-Term Support (LTS) version like OpenJDK 17 or OpenJDK 21 to ensure application stability. These versions provide long-term security updates and are widely supported by enterprise frameworks.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How do I switch between multiple Java versions on Ubuntu?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">You can switch versions using the <code>sudo update-alternatives --config java<\/code> command. This opens a list of installed Java environments where you can type the selection number of the version you want to set as the default.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Can I install Java on Ubuntu without root privileges?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The guide describes installation using <code>sudo<\/code>, which requires administrative root privileges to write to system directories like <code>\/usr\/lib\/jvm\/<\/code>. Without root access, you cannot use the apt package manager to install Java system-wide.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How do I check if javac is installed correctly on my server?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Run the command <code>javac -version<\/code> in your terminal. If installed correctly, the system will return the version string of the Java compiler, such as <code>javac 17.0.x<\/code>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Master the terminal steps to install Java on Ubuntu 24.04 and 22.04 LTS servers. Follow our developer-tested commands for a secure production setup.<\/p>\n","protected":false},"author":4,"featured_media":12008,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","rank_math_title":"Install Java Ubuntu: Step-by-Step Terminal Guide","rank_math_description":"Learn how to install Java on Ubuntu 24.04 and 22.04 using the command line. Follow our proven steps, configure LTS versions, and deploy today.","rank_math_focus_keyword":"install java ubuntu, how to install java on ubuntu, install java ubuntu 24.04","rank_math_canonical_url":"","rank_math_facebook_image":"","rank_math_facebook_image_id":0,"xseo_schema_type":"","xseo_sitemap_exclude":false,"rank_math_robots":[],"_xseo_takeaways":["Update package lists using apt update before installing any software.","Install OpenJDK 17 or OpenJDK 21 for long-term production stability.","Verify your active Java installation using the java -version command.","Manage multiple Java installations easily with update-alternatives.","Deploy your Java workloads on scalable Linux VPS infrastructure in India."]},"categories":[36],"tags":[],"class_list":["post-10150","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/xenaxcloud.com\/blog\/wp-json\/wp\/v2\/posts\/10150","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xenaxcloud.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xenaxcloud.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xenaxcloud.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/xenaxcloud.com\/blog\/wp-json\/wp\/v2\/comments?post=10150"}],"version-history":[{"count":4,"href":"https:\/\/xenaxcloud.com\/blog\/wp-json\/wp\/v2\/posts\/10150\/revisions"}],"predecessor-version":[{"id":12009,"href":"https:\/\/xenaxcloud.com\/blog\/wp-json\/wp\/v2\/posts\/10150\/revisions\/12009"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/xenaxcloud.com\/blog\/wp-json\/wp\/v2\/media\/12008"}],"wp:attachment":[{"href":"https:\/\/xenaxcloud.com\/blog\/wp-json\/wp\/v2\/media?parent=10150"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xenaxcloud.com\/blog\/wp-json\/wp\/v2\/categories?post=10150"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xenaxcloud.com\/blog\/wp-json\/wp\/v2\/tags?post=10150"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}