Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I've installed Oracle Java. I want to be able to remove OpenJDK, but when trying to do so apt wants to install another version of Java.

How can I configure apt so that it knows I already have a third-party Java installed so I can remove these OpenJDK packages?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

Create a dummy package using equivs. In a nutshell:

  1. Create a control file for the dummy package. The program equiv-controls creates a template. Give it a file name.

    equivs-control oracle-jre.control
  2. Edit the control file. At least set the Package: line to sun-java6-jre (the name of the defunct Sun/Oracle Java package). You should also write a meaningful Description:, set the section to java. Declare that the package Provides: java-6-runtime and other versions (this is the virtual package that other programs depend on, can find this out by checking what openjdk-6-jre provides and what various programs require). The file might look like this:

    Section: java
    Priority: optional
    Standards-version: 3.9.2
    Package: sun-6-jre
    Provides: java6-runtime, java-runtime
    Description: dummy package when Oracle Java is installed
  3. Create a Debian package with the control file you created. This package is only there for the dependencies and installs no file.

    equivs-build oracle-jre.control
  4. Install the resulting deb package.

    sudo dpkg -i sun-6-jre_1.0_all.deb
share|improve this answer

I do not believe there is a method for doing this. In lieu of using a PPA repository that provides you with .deb packages of Java, you could give this script a try which will roll you're own .deb packages of the Java installation.

This script is called OAB-Java, specifically


Downloading the script:

cd ~/
wget -O
chmod +x
sudo ./

The script takes the following switches:

  • -7 : Build oracle-java7 packages instead of sun-java6
  • -c : Remove pre-existing packages from /var/local/oab/deb and sources from /var/local/oab/src.
  • -k : Use the specified existing key instead of generating one
  • -s : Skip building if the packages already exist
  • -t : Specify the Java version tag to use from the upstream Debian packaging script.
  • -h : This help

To prepare & install the Oracle 6 .deb files:

$ sudo ./
$ sudo apt-get install sun-java6-jre

To prepare & install the Oracle 7 .deb files:

$ sudo ./ -7
$ sudo apt-get install oracle-java7-jre
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.