Blog · WebJi® India

How to Install Java on Ubuntu

Quick answer: How to Install Java on Ubuntu from WebJi®, billed in INR with 18% GST on the invoice. Email support@webji.services is 24/7 in Hindi and English (average first reply under 60 minutes). Phone +91 141 4941811 is business hours only. The company has been in this business since 2005.
✓ In business since 2005✓ INR + GST billing✓ 24/7 Email Support — avg reply < 60 min
Sealed cardboard moving boxes with a laptop in an office hallway, symbolising website migration — how to install java on ubuntu

JDK vs JRE: What to Install

Two commands for the default JDK:

  1. sudo apt update && sudo apt install default-jdk -y — installs Ubuntu's preferred OpenJDK (Java 21 LTS on modern releases).
  2. java -version to verify, plus javac -version — the compiler's presence confirms a full JDK, not a bare JRE.

JDK versus JRE, the choice that prevents reinstalling later: the JRE runs Java programs; the JDK adds the compiler and development tools. Running applications needs only the headless JRE (openjdk-21-jre-headless — no GUI libraries, ideal for servers); building or deploying Tomcat-class apps needs the JDK.

Installing the Default JDK via apt

Installing the Default JDK via apt. Do the change this heading names on one site first, then check it in a private browser window or in the mail client, depending on the topic. Change one setting at a time, and undo it if the result is wrong before you try the next. If you want the Jaipur desk to look with you, email support@webji.services — that mailbox is staffed 24/7 in Hindi and English. Phone +91 141 4941811 is business hours only.

Sealed cardboard moving boxes with a laptop in an office hallway, symbolising website migration — how to install java on ubuntu

Installing Specific Versions (17, 21, headless)

Installing Specific Versions (17, 21, headless). Do the change this heading names on one site first, then check it in a private browser window or in the mail client, depending on the topic. Change one setting at a time, and undo it if the result is wrong before you try the next. If you want the Jaipur desk to look with you, email support@webji.services — that mailbox is staffed 24/7 in Hindi and English. Phone +91 141 4941811 is business hours only.

Verifying the Installation

Verifying the Installation. Do the change this heading names on one site first, then check it in a private browser window or in the mail client, depending on the topic. Change one setting at a time, and undo it if the result is wrong before you try the next. If you want the Jaipur desk to look with you, email support@webji.services — that mailbox is staffed 24/7 in Hindi and English. Phone +91 141 4941811 is business hours only.

Setting JAVA_HOME Permanently

JAVA_HOME is the environment variable build tools (Maven, Gradle, Tomcat wrappers, systemd services) read:

  1. Find your exact path: ls /usr/lib/jvm/ — e.g. /usr/lib/jvm/java-21-openjdk-amd64.
  2. Set it system-wide: edit /etc/environment and add JAVA_HOME="/usr/lib/jvm/java-21-openjdk-amd64".
  3. Per-user alternative: append the export line to ~/.bashrc, then source ~/.bashrc.
  4. Verify with echo $JAVA_HOME in a fresh shell.

Switching versions later is update-alternatives' job — sudo update-alternatives --config java lists installed JREs; pick a number and the default moves without touching JAVA_HOME.

Not connected yet? The PuTTY guide covers the first login.

Switching Default Versions with update-alternatives

On update-alternatives version switching, the honest summary is that defaults matter more than brand names — a well-set budget plan outranks a mis-tuned premium one. WebJi® documents its defaults openly and adjusts them per ticket when workloads need it.

Server Tips: Headless JRE and Memory Settings

How this plays out with java -version verification: settings that look cosmetic usually decide page speed and uptime under real traffic. The defaults WebJi® ships are tuned for Indian network conditions, and support can review your setup on request.

Frequently Asked Questions

How do I install Java on Ubuntu 24.04?

sudo apt update && sudo apt install default-jdk -y — installs Ubuntu's preferred OpenJDK (Java 21 LTS on modern releases).

What is the difference between JDK and JRE?

java -version to verify, plus javac -version — the compiler's presence confirms a full JDK, not a bare JRE.

How do I install a specific version like Java 17 or 21?

sudo apt update && sudo apt install default-jdk -y — installs Ubuntu's preferred OpenJDK (Java 21 LTS on modern releases). The question here is: How do I install a specific version like Java 17 or 21.

How do I set JAVA_HOME on Ubuntu?

sudo apt update && sudo apt install default-jdk -y — installs Ubuntu's preferred OpenJDK (Java 21 LTS on modern releases). The question here is: How do I set JAVA_HOME on Ubuntu.

How do I switch between installed Java versions?

Switching versions later is update-alternatives' job — sudo update-alternatives --config java lists installed JREs; pick a number and the default moves without touching JAVA_HOME.

How do I check which Java version is active?

java -version to verify, plus javac -version — the compiler's presence confirms a full JDK, not a bare JRE. The question here is: How do I check which Java version is active.

Is WebJi® an Indian company?

Yes. WebJi® is headquartered in Jaipur, Rajasthan and has operated since 2005. Billing, support and governance all run from India.

Do you provide GST invoices?

Every purchase and renewal gets a GST invoice with our GSTIN, and hosting prices are quoted exclusive of 18% GST. Claim input credit as applicable.

Need help with this?

WebJi® support does it for you — free. Talk to our Jaipur team →