Of course. Here is a comprehensive guide on how to install and use Java 1.6 (also known as Java 6) on Ubuntu.

⚠️ Important Security and Compatibility Warning
Before you proceed, it is critically important to understand the following:
- End of Life (EOL): Java 1.6 reached its official End of Life in February 2025. This means it no longer receives security updates, bug fixes, or performance improvements.
- Major Security Risk: Running Java 1.6 on a machine connected to the internet is a significant security vulnerability. It can be easily exploited by malware.
- Modern Software Compatibility: Almost all modern Java applications, frameworks (like Spring Boot, Hibernate), and build tools (like Maven, Gradle) require Java 8 or newer. They will not run on Java 1.6.
You should only use Java 1.6 if you are:
- Maintaining a legacy, closed-off application that cannot be upgraded.
- Working on a project for an educational purpose where you are required to use this specific version.
- Running it on a machine that is completely isolated from any network.
Why You Can't Find Java 1.6 in Standard Ubuntu Repositories
Starting with Ubuntu 14.04, the default repositories removed OpenJDK 6 and Oracle JDK 6 due to their EOL status. Modern versions of Ubuntu (16.04, 18.04, 20.04, 22.04, 24.04) do not have Java 1.6 packages available in their main software archives.
Therefore, you have to get it from an alternative source. The most reliable method is to use a PPA (Personal Package Archive), which is a community-maintained software repository.

Method 1: Using a Community PPA (Recommended for Ubuntu 14.04 - 18.04)
This is the easiest method if you are on an older version of Ubuntu that can still support it.
Step 1: Add the PPA
The ppa:openjdk-r/ppa is a well-known repository for older OpenJDK versions. Open your terminal and add it:
sudo add-apt-repository ppa:openjdk-r/ppa
You may be prompted to press Enter to continue. Do so.

Step 2: Update Your Package List
After adding the PPA, you need to update your system's list of available packages:
sudo apt-get update
Step 3: Install OpenJDK 6
Now you can install the Java 6 Development Kit (JDK) or the Java 6 Runtime Environment (JRE).
-
To install the JDK (recommended, includes the JRE):
sudo apt-get install openjdk-6-jdk
-
To install only the JRE (if you just need to run Java programs):
sudo apt-get install openjdk-6-jre
Step 4: Verify the Installation
Check the Java version to confirm it's installed correctly:
java -version
You should see output similar to this:
java version "1.6.0_45"
OpenJDK Runtime Environment (IcedTea6 1.13.13) (6b45-1.13.13-1ubuntu0.14.04.2)
OpenJDK 64-Bit Server VM (build 20.45-b15, mixed mode)
You can also check the compiler:
javac -version
Output:
javac 1.6.0_45
Method 2: Manual Installation (More Universal)
This method involves downloading the JDK directly from Oracle's archives and installing it manually. This is useful if the PPA method doesn't work for your specific Ubuntu version.
Step 1: Download the Oracle JDK 6
Go to the Oracle Java Archive and download the JDK for Linux x64.
- Oracle Java Archive JDK 6 Downloads: https://www.oracle.com/java/technologies/javase/javase-archive-downloads-javase6.html
You will need to accept the license agreement. Find the link for JDK 6u45 (or a later update in the 6 series) and download the .bin file for Linux x64.
Step 2: Create a Directory for Java
It's good practice to install Java in /usr/lib/jvm.
sudo mkdir -p /usr/lib/jvm
Step 3: Move and Extract the JDK
Move the downloaded file to the /usr/lib/jvm directory and make it executable.
# Replace jdk-6u45-linux-x64.bin with the actual name of your file sudo mv ~/Downloads/jdk-6u45-linux-x64.bin /usr/lib/jvm/ cd /usr/lib/jvm/ sudo chmod +x jdk-6u45-linux-x64.bin
Now, extract it:
sudo ./jdk-6u45-linux-x64.bin
Follow the on-screen prompts (just press Enter to accept the license). This will create a directory like jdk1.6.0_45.
Step 4: Set Up Environment Variables
You need to tell your system where to find Java.
-
Set
JAVA_HOME: Edit the/etc/environmentfile. Use a text editor likenano:sudo nano /etc/environment
Add the following line at the end of the file. Be sure to use the correct directory name for your JDK version.
JAVA_HOME="/usr/lib/jvm/jdk1.6.0_45"
Save the file (
Ctrl+O, thenEnter) and exit (Ctrl+X). -
Update the
PATH: Edit the~/.bashrcfile for your current user:nano ~/.bashrc
Add the following lines to the end of the file:
export JAVA_HOME=/usr/lib/jvm/jdk1.6.0_45 export PATH=$JAVA_HOME/bin:$PATH
Save and exit. Then, apply the changes to your current terminal session:
source ~/.bashrc
Step 5: Verify the Installation
Check the version again:
java -version javac -version
How to Manage Multiple Java Versions (Update Alternatives)
If you have multiple Java versions installed (e.g., Java 11 and Java 6), you can use update-alternatives to switch between them easily.
-
Register the Java 6 installation with
update-alternatives:sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.6.0_45/bin/java 1060 sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.6.0_45/bin/javac 1060
(The number
1060is a priority; higher numbers take precedence. Use a number lower than your other Java versions if you want Java 6 to be the default.) -
Configure the Default Java Version: Run the following command to choose which version to use by default:
sudo update-alternatives --config java
You will see a list of installed Java versions. Enter the number corresponding to Java 1.6 to select it.
Do the same for
javac:sudo update-alternatives --config javac
Summary
| Method | Pros | Cons | Best For |
|---|---|---|---|
| PPA | Easy, managed by apt, handles dependencies. |
Only works on older Ubuntu versions. | Ubuntu 14.04, 16.04, 18.04. |
| Manual Install | Works on any Linux distro, full control. | More steps, manual updates, managing PATH. |
Newer Ubuntu versions or specific needs. |
Again, please use Java 1.6 with extreme caution and only when absolutely necessary. For any new project, please use a modern, supported version of Java.
