What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
For most Ubuntu users, install the distribution’s default Java Development Kit with:
sudo apt update
sudo apt install default-jdk
Then verify both the Java runtime and compiler:
java --version
javac --version
default-jdk is Ubuntu’s release-specific JDK choice, so it does not guarantee the same Java feature release on every Ubuntu version. If a project requires a particular release, install its versioned OpenJDK package instead.
Before you install
Check your Ubuntu release
This guide focuses on supported Ubuntu releases, including Ubuntu 22.04 LTS, 24.04 LTS and 26.04 LTS. Check yours with:
. /etc/os-release
echo "$PRETTY_NAME"
You can also use lsb_release -a. Ubuntu’s supported documentation index is at help.ubuntu.com.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Check the CPU architecture
dpkg --print-architecture
uname -m
amd64 normally means 64-bit Intel or AMD hardware; arm64 means 64-bit ARM. Architecture matters particularly when downloading vendor binaries.
JRE versus JDK
A Java Runtime Environment runs Java applications. A Java Development Kit includes the runtime plus development tools such as javac, jar, javadoc, jdb and jconsole. Maven, Gradle, IDEs, Android tooling and Java application builds generally need the JDK. Installing only default-jre can leave javac unavailable. Ubuntu distinguishes these paths in its JRE guide.
Install Ubuntu’s default JDK
-
Refresh APT’s package indexes:
sudo apt updateThis refreshes package metadata; it does not upgrade Ubuntu itself.
-
Install the default JDK:
sudo apt install default-jdk -
Accept the confirmation prompt. APT installs the JDK and registers its commands with Ubuntu’s alternatives system.
Recommended Free Tools
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Ubuntu documents this as the normal developer installation method at ubuntu.com/developers/docs/howto/java-setup/. The default-jdk package is an alias for the release’s chosen default, not a globally fixed Java version. Ubuntu’s availability table lists OpenJDK 8, 11, 17, 21 and 25 for Ubuntu 24.04 LTS, and those releases plus 26 for Ubuntu 26.04 LTS; package availability varies by release and repository state (availability table).
Verify Java and the compiler
Check both commands:
java --version
javac --version
command -v java
command -v javac
Patch numbers and vendor suffixes can change with Ubuntu updates, so do not expect one exact version string. To inspect the actual executables:
readlink -f "$(command -v java)"
readlink -f "$(command -v javac)"
A working JDK must expose javac as well as java.
Compile a complete test program
mkdir -p ~/java-test
cd ~/java-test
cat > Hello.java <<'EOF'
public class Hello {
public static void main(String[] args) {
System.out.println("Java works");
}
}
EOF
javac Hello.java
java Hello
Expected output:
Java works
Remove the test directory when finished if you wish:
Rank #2
rm -rf ~/java-test
Install a specific Java feature release
Use a versioned package when a project, build tool, Android setup, application server or vendor support matrix requires a particular release:
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemssudo apt update
sudo apt install openjdk-21-jdk
Other examples are:
sudo apt install openjdk-17-jdk
sudo apt install openjdk-25-jdk
Replace the number with the required feature release. Do not assume that a package available on one Ubuntu release exists on another. Check first:
apt-cache search '^openjdk-[0-9]+-jdk$'
apt policy openjdk-21-jdk
Ubuntu’s Java availability table is the authority for release-specific availability. Ubuntu documentation updated in June 2026 uses OpenJDK 21 as an LTS example, while the later availability table lists OpenJDK 25 in current releases; therefore, choose the version your project requires rather than relying on a universal “latest” label.
Choosing between common packages
| Choice | Best for | Trade-off |
|---|---|---|
default-jdk |
Most Ubuntu installations | The selected feature release differs by Ubuntu release. |
openjdk-17-jdk |
Projects pinned to Java 17 | Older than newer releases. |
openjdk-21-jdk |
Projects explicitly requiring Java 21 | Not necessarily Ubuntu’s default everywhere. |
openjdk-25-jdk |
Projects targeting Java 25 | Unavailable on some older Ubuntu releases. |
Manage multiple installed JDKs
List registered JDK installations:
update-java-alternatives --list
To select the default runtime and compiler independently:
sudo update-alternatives --config java
sudo update-alternatives --config javac
Select the desired entry from each prompt, then verify both:
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →java --version
javac --version
Switching only java can leave the runtime and compiler on different feature releases. Where a complete registered JDK is listed, update-java-alternatives can switch its alternatives together:
sudo update-java-alternatives --set <JDK-name>
Its behavior and syntax are documented in the Ubuntu manpage.
Set JAVA_HOME only when needed
Many modern tools find Java through PATH, so setting JAVA_HOME is not mandatory. Use it when Maven, Gradle, Jenkins, Tomcat, an IDE or a script explicitly requires a JDK directory, or when you want a stable per-project selection.
Find the active JDK directory
dirname "$(dirname "$(readlink -f "$(command -v javac)")")"
Set it for the current shell
export JAVA_HOME="$(dirname "$(dirname "$(readlink -f "$(command -v javac)")")")"
export PATH="$JAVA_HOME/bin:$PATH"
echo "$JAVA_HOME"
"$JAVA_HOME/bin/java" --version
"$JAVA_HOME/bin/javac" --version
Persist it for Bash
cat >> ~/.bashrc <<'EOF'
export JAVA_HOME="$(dirname "$(dirname "$(readlink -f "$(command -v javac)")")")"
export PATH="$JAVA_HOME/bin:$PATH"
EOF
source ~/.bashrc
Graphical applications, IDEs and system services may not read your interactive Bash startup files. Configure those applications or service units separately when necessary. For a system-wide shell setting, use a file under /etc/profile.d/ rather than modifying every user’s shell file.
Free tools Windows power users keep installed
One-click scans. No signup required.
If you only need to run Java applications
For runtime-only use, Ubuntu provides:
sudo apt update
sudo apt install default-jre
A version-specific runtime is available with, for example:
sudo apt install openjdk-21-jre
That is sufficient for launching Java programs, but not for compiling source code.
Oracle JDK and other distributions
Oracle JDK
Use Oracle JDK when a vendor or enterprise policy explicitly requires Oracle’s distribution, official Oracle binaries or an Oracle support relationship. Oracle provides Linux .deb packages for Debian-based systems and .tar.gz archives for private or non-root installations. Its packages integrate with Linux alternatives and use paths such as /usr/lib/jvm/jdk-<VERSION>-oracle-<ARCH>. Follow Oracle’s current instructions at docs.oracle.com/en/java/javase/26/install/installation-jdk-linux-platforms.html and obtain downloads from Oracle’s download page. Oracle JDK is not required for ordinary Ubuntu Java development; OpenJDK from APT is simpler to update.
GraalVM Community Edition
GraalVM is a specialized JDK useful for Native Image and other advanced runtime workflows:
sudo snap install graalvm-jdk
sudo snap install graalvm-jdk --channel=v21
Ubuntu lists GraalVM support for Ubuntu 24.04 LTS and later in its availability documentation. It is unnecessary complexity for normal Java, Maven or Gradle work.
Rank #4
Troubleshooting
“Unable to locate package openjdk-XX-jdk”
Refresh indexes and inspect what your release provides:
sudo apt update
apt-cache policy openjdk-21-jdk
apt-cache search openjdk
The requested release may not be packaged for your Ubuntu version, package indexes may be stale, or a required repository may not be enabled. Use a version listed for your release instead of copying a command from another release.
java works but javac is missing
You likely installed a JRE. Install the default or matching versioned JDK:
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchPC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11sudo apt install default-jdk
# or
sudo apt install openjdk-21-jdk
The wrong Java version is selected
update-java-alternatives --list
sudo update-alternatives --config java
sudo update-alternatives --config javac
java --version
javac --version
JAVA_HOME points somewhere incorrect
Derive it from the active compiler rather than guessing a directory name:
dirname "$(dirname "$(readlink -f "$(command -v javac)")")"
Export that result as JAVA_HOME, and check that both $JAVA_HOME/bin/java and $JAVA_HOME/bin/javac exist.
A project needs an older release
Install both releases and select the required one with alternatives or in the project’s IDE/build-tool configuration:
sudo apt install openjdk-17-jdk openjdk-21-jdk
There is usually no need to uninstall the newer JDK.
Best Value
You are on an unsupported Ubuntu release
Prefer upgrading to a supported Ubuntu release. If that is not immediately possible, use a JDK package available for the current release or an official vendor .deb or archive when a specific version is genuinely required. Avoid random third-party PPAs as the first fix.
Architecture mismatch
Confirm the machine architecture before downloading a vendor build:
dpkg --print-architecture
uname -m
Oracle publishes separate Linux x64 and Linux aarch64 downloads; they are not interchangeable.
A manually unpacked JDK is not visible to alternatives
Tarballs do not necessarily register java and javac. If your JDK is at a real path such as /opt/jdk-<version>, register both commands:
sudo update-alternatives --install /usr/bin/java java /opt/jdk-<version>/bin/java 1
sudo update-alternatives --install /usr/bin/javac javac /opt/jdk-<version>/bin/javac 1
sudo update-alternatives --config java
sudo update-alternatives --config javac
Manual installations require you to manage updates, PATH, JAVA_HOME and alternatives yourself, so use APT unless you specifically need a portable or non-root installation.
Optional Java development tools
Install an IDE only after the JDK is working. Ubuntu lists these Snap routes:
sudo snap install eclipse --classicfor Eclipse.sudo snap install intellij-idea-community --classicfor IntelliJ IDEA Community Edition.sudo snap install code --classicfor Visual Studio Code, followed by Java extensions.sudo snap install android-studio --classicfor Android development.
See Ubuntu’s developer setup documentation for its current tool list.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




