How to Install JDK on Linux Full Version Not Headless
Installing the full version of the Java Development Kit (JDK) on Linux can sometimes be confusing, especially when you want the complete package and not just the headless version. If you’re a developer or just someone who needs the full Java environment with GUI support, this guide will help you get it right. I’ll walk you through the steps to install the full JDK on your Linux system, ensuring you have all the tools you need.
You might wonder why the headless version is often installed by default. It’s because the headless JDK is a lighter version designed for servers without graphical interfaces. But if you want to run Java applications that require GUI components or develop Java apps with full features, the full JDK is essential. Let’s dive into how you can install it on popular Linux distributions.
Understanding the Difference: Full JDK vs Headless JDK
Before installing, it’s important to know what sets the full JDK apart from the headless version. The headless JDK excludes graphical libraries like AWT and Swing, which are necessary for GUI applications.
- Full JDK includes:
- Java compiler (javac)
- Java runtime environment (JRE) with GUI libraries
- Development tools and utilities
- Headless JDK includes:
- Java compiler and runtime without GUI libraries
- Suitable for server environments or command-line applications
If you install the headless version by mistake, you might face errors when running GUI-based Java programs. So, always check which package you’re installing.
How to Check if You Have JDK Installed on Linux
Before installing, you can check if JDK is already installed and which version you have.
Open your terminal and type:
java -version
If Java is installed, you’ll see output like:
openjdk version "17.0.5" 2026-04-20
OpenJDK Runtime Environment (build 17.0.5+8)
OpenJDK 64-Bit Server VM (build 17.0.5+8, mixed mode)
To check if the compiler is installed:
javac -version
If you get a command not found error or see a headless version, you’ll need to install the full JDK.
Installing Full JDK on Ubuntu and Debian-Based Systems
Ubuntu and Debian often default to installing the headless JDK when you use the generic default-jdk package. To install the full JDK, follow these steps:
- Update your package list:
sudo apt update
- Search for available JDK packages:
apt search openjdk
Look for packages like openjdk-17-jdk or openjdk-11-jdk. Avoid packages with headless in their name.
- Install the full JDK package:
For example, to install OpenJDK 17 full version:
sudo apt install openjdk-17-jdk
This package includes the full JDK with GUI libraries.
- Verify the installation:
java -version
javac -version
You should see the full JDK version without any mention of headless.
Tips for Ubuntu/Debian Users
- Avoid installing
openjdk-17-jdk-headlessunless you specifically want the headless version. - If you have the headless version installed, remove it first:
sudo apt remove openjdk-17-jdk-headless
- You can install multiple JDK versions and switch between them using
update-alternatives.
Installing Full JDK on Fedora, CentOS, and RHEL
For Red Hat-based distributions like Fedora, CentOS, and RHEL, the process is slightly different but straightforward.
- Update your system:
sudo dnf update
- Search for available JDK packages:
dnf search openjdk
- Install the full JDK package:
For example, to install OpenJDK 17:
sudo dnf install java-17-openjdk-devel
The -devel package includes the full development kit with GUI support.
- Verify the installation:
java -version
javac -version
Notes for Fedora/CentOS/RHEL Users
- The package
java-17-openjdkis usually the runtime only. - The
java-17-openjdk-develpackage contains the compiler and full JDK. - Avoid installing
java-17-openjdk-headlessunless you want the minimal version.
Installing Oracle JDK Full Version on Linux
Some developers prefer Oracle’s official JDK for its performance and support. Installing Oracle JDK on Linux requires manual steps since it’s not always available in default repositories.
- Download Oracle JDK:
Go to the official Oracle website and download the Linux tar.gz package for the full JDK version you want.
- Extract the archive:
tar -xzf jdk-17_linux-x64_bin.tar.gz
- Move the extracted folder to
/usr/local/java:
sudo mkdir -p /usr/local/java
sudo mv jdk-17 /usr/local/java/
- Set environment variables:
Edit your .bashrc or .bash_profile:
export JAVA_HOME=/usr/local/java/jdk-17
export PATH=$JAVA_HOME/bin:$PATH
Reload the profile:
source ~/.bashrc
- Verify installation:
java -version
javac -version
Oracle JDK includes the full set of tools and GUI libraries by default.
Switching Between Multiple JDK Versions on Linux
If you have multiple JDK versions installed, you can switch between them easily.
On Debian/Ubuntu:
sudo update-alternatives --config java
sudo update-alternatives --config javac
On Fedora/CentOS/RHEL:
sudo alternatives --config java
sudo alternatives --config javac
This lets you select the default JDK version system-wide.
Troubleshooting Common Issues
Sometimes, even after installing the full JDK, you might face issues.
Error: Could not find or load main class
This might mean yourJAVA_HOMEorPATHis not set correctly.GUI applications fail to run
Confirm you installed the full JDK, not the headless version.Multiple Java versions causing conflicts
Use the alternatives system to select the correct version.Permission denied errors
Ensure you have proper permissions for JDK directories.
Summary Table: JDK Packages by Distribution
| Distribution | Full JDK Package Name | Headless Package Name |
| Ubuntu/Debian | openjdk-17-jdk | openjdk-17-jdk-headless |
| Fedora/CentOS/RHEL | java-17-openjdk-devel | java-17-openjdk-headless |
| Oracle JDK | Manual download and install | N/A |
Conclusion
Installing the full version of the JDK on Linux is essential if you want complete Java development capabilities, including GUI support. Whether you use Ubuntu, Fedora, or prefer Oracle’s official JDK, the key is to avoid the headless packages that omit graphical libraries. By following the steps above, you can ensure your Linux system has the full JDK installed and configured properly.
Remember to verify your installation and set environment variables correctly. If you manage multiple JDK versions, use the alternatives system to switch between them easily. With the full JDK installed, you’re ready to develop and run any Java application on your Linux machine.
FAQs
How do I know if I have the headless JDK installed?
Run java -version. If it mentions "headless" or you installed a package with "headless" in its name, you have the headless JDK. Also, GUI apps may fail to run.
Can I install multiple JDK versions on Linux?
Yes, you can install multiple versions and switch between them using update-alternatives on Debian/Ubuntu or alternatives on Fedora/CentOS.
Is Oracle JDK better than OpenJDK?
Oracle JDK offers commercial support and some performance optimizations, but OpenJDK is fully open-source and widely used. Both are compatible for most development needs.
How do I set JAVA_HOME on Linux?
Add export JAVA_HOME=/path/to/jdk and export PATH=$JAVA_HOME/bin:$PATH to your shell profile file like .bashrc or .bash_profile.
What if my GUI Java apps still don’t run after installing full JDK?
Check your environment variables and ensure you didn’t accidentally install the headless version. Also, verify your Java application’s dependencies and permissions.
