Ubuntu 16.04安装oracle-java6-installer报错,求Java6替代安装方案
Since Oracle has removed public download links for Java 6, the oracle-java6-installer package can no longer fetch the required binary automatically. Here are two practical methods to get Java 6 up and running for your legacy application:
Method 1: Manual Installation of Oracle Java 6
This method lets you use a local copy of the Java 6 binary (you’ll need to obtain this legally—check old backups or trusted archival sources for an unmodified jdk-6u45-linux-x64.bin file):
- Make the binary executable:
Navigate to the directory where you saved the file in terminal, then run:chmod +x jdk-6u45-linux-x64.bin - Extract the JDK files:
Execute the binary to unpack the JDK:
This will create a folder named./jdk-6u45-linux-x64.binjdk1.6.0_45. - Move to a standard system location:
Usesudoto place the JDK in the common Java directory:sudo mkdir -p /usr/lib/jvm sudo mv jdk1.6.0_45 /usr/lib/jvm/ - Register with system alternatives:
Tell Ubuntu about this new Java installation:sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.6.0_45/bin/java 100 sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.6.0_45/bin/javac 100 - Set as default (optional):
If you want Java 6 to be the system’s default, run:
Then enter the number corresponding tosudo update-alternatives --config java/usr/lib/jvm/jdk1.6.0_45/bin/java. - Verify the installation:
Check if Java 6 is working:
You should see output like this:java -versionjava version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)
Method 2: Use OpenJDK 6 (If Your App Supports It)
Some legacy apps work with OpenJDK 6 instead of Oracle’s version. Since Ubuntu 16.04’s default repos don’t include it, you can temporarily enable older Ubuntu repos to install it:
- Add the trusty repository:
sudo add-apt-repository "deb http://old-releases.ubuntu.com/ubuntu/ trusty main universe" - Update package lists:
sudo apt-get update - Install OpenJDK 6:
sudo apt-get install openjdk-6-jdk - Register with system alternatives:
Follow step 4 from Method 1 to set OpenJDK 6 as an option, and step 5 if you want it as default. - Remove the old repo (recommended):
To avoid conflicts with newer packages, disable the trusty repo after installation:sudo add-apt-repository --remove "deb http://old-releases.ubuntu.com/ubuntu/ trusty main universe" sudo apt-get update
Important Notes
- Java 6 is no longer supported (no security updates), so use it only for your specific legacy app and keep it isolated from other systems if possible.
- Always verify the integrity of any downloaded Java binary to avoid malware risks.
内容的提问来源于stack exchange,提问作者Manas Ranjan Mohapatra

