4
java -version
java version "1.6.0_18"
OpenJDK Runtime Environment (IcedTea6 1.8.13) (6b18-1.8.13-0+squeeze2)
OpenJDK 64-Bit Server VM (build 14.0-b16, mixed mode)

There doesn't seem to be an easy way to search for packages in apt so I'm using dpkg to search for java-related packages:

# dpkg --get-selections | less | grep java
ca-certificates-java            install
java-common                     install
javascript-common               install
libaccess-bridge-java           install
libaccess-bridge-java-jni       install
libdb4.7-java-gcj               deinstall
libhsqldb-java-gcj              deinstall
sun-java6-bin                   deinstall
sun-java6-jre                   deinstall
tzdata-java                     install

I proceed to remove java-common, however when it finishes java is still installed and java -version still shows the same thing.

Nothing changes, the java-common package even still appears in the dpkg search. What am I missing?

I also removed OpenJDK, which seemed to set it to "deinstall":

# dpkg --get-selections | less | grep openjdk
openjdk-6-jre                   deinstall
openjdk-6-jre-headless          install
openjdk-6-jre-lib               install

Java is still there.

# java -version
java version "1.6.0_18"
OpenJDK Runtime Environment (IcedTea6 1.8.13) (6b18-1.8.13-0+squeeze2)
OpenJDK 64-Bit Server VM (build 14.0-b16, mixed mode)
6
  • How exactly did you remove the packages? Because deinstall just means that it is selected for deinstallation, but not actually deinstalled. Jun 16, 2013 at 3:06
  • 1
    Also, there is something strange about the order in your pipes: do you have any reason for having less before grep? Jun 16, 2013 at 3:07
  • I used apt-cache remove <package> to remove them, and they showed up as "deinstall" in dpkg -- not sure if that's normal.
    – some1
    Jun 16, 2013 at 8:01
  • There was too much output and I tried less before I grepped. ;p You're right it makes no sense as is.
    – some1
    Jun 16, 2013 at 8:02
  • Are you sure you used apt-cache? As far as I know apt-cache does not even have a remove command, anyway, apt-cache is for querying the apt cache, not for installing and unistalling packages. Using apt-get remove <package>, or apt-get purge <package> would be better. I myself use aptitude for tasks like that, it has nice user interface, or if you want something with a GUI, synaptic is supposed to be good. Jun 16, 2013 at 14:22

3 Answers 3

10

For me it was:

sudo apt-get remove openjdk-6*
sudo apt-get remove icedtea*
0
3

I came across this because I am working through an instructional book for android programming which wants to use a specific Java SE and JRE (8u121) and requests that all other java packages be removed before continuing with the installation. So after reading the above ideas I went with:

sudo apt-get remove openjdk*

and the result was:

bryan@kali:~$ java -version
bash: /usr/bin/java: No such file or directory

So the above suggests that there is no java found of any version. Which is the OP wanted to do (I think).

In case somebody finds this thread because they are uninstalling Java so that they can install an Old Version, I have included a walk-through I found. The first two codes help you install it if you had no GUI. If you have a tarball then skip those. The last codeblock has some parts that you'll need to edit if you are not installing my same version.


{begin copy/paste}

In case that you are attempting to install Java JDK remotely and have absolutely no access to Graphical User Interface and web browser use the following curl method to download Java JDK using a command line.

First, obtain a correct download URL by using the curl command:

$ curl -s http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html | grep "otn-pub" | cut -d \" -f12

The above command outputs a bunch of URLs for your selection. To initiate the download of the desired Java file, copy its URL and start the download using the curl command while accepting the requested Jave license. For example:

$ curl -LOb "oraclelicense=a" http://download.oracle.com/otn-pub/java/jdk/8u121-b13/e9e7ea248e2c4826b92b3f075a80e441/jdk-8u121-linux-x64.tar.gz

Install Java JDK At this stage, we should have an appropriate Java JDK tarball within our current working directory:

$ ls
jdk-8u121-linux-x64.tar.gz

Create a target Java JDK installation directory:

# mkdir /opt/java-jdk

Extract the previously downloaded Java JDK tarball:

# tar -C /opt/java-jdk -zxf jdk-8u121-linux-x64.tar.gz

Set Oracle Java as default Currently, the system does not recognise our Java JDK installation:

$ update-alternatives --list java
update-alternatives: error: no alternatives for java
$ java
bash: java: command not found

Use the update-alternatives command to inlcude both, java and javac as part of the system's Java environment.Please replace the below path to java binaries where appropriate to reflect your downloaded java version:

# update-alternatives --install /usr/bin/java java /opt/java-jdk/jdk1.8.0_121/bin/java 1   
update-alternatives: using /opt/java-jdk/jdk1.8.0_121/bin/java to provide /usr/bin/java (java) in auto mode
# update-alternatives --install /usr/bin/javac javac /opt/java-jdk/jdk1.8.0_121/bin/javac 1
update-alternatives: using /opt/java-jdk/jdk1.8.0_121/bin/javac to provide /usr/bin/javac (javac) in auto mode

{end copy/paste}

Okay so after I followed that I wanted to confirm that it works...

bryan@kali:~/Desktop$ java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

That's it! That's what we want.

Then I became concerned that it 'apt update' may just undo what I did by updating the package (unsure). So I put them on hold. To remove hold: apt-mark unhold.

bryan@kali:~/Desktop$ sudo apt-mark hold openjdk-8*
openjdk-8-jre set on hold.
openjdk-8-jre-headless set on hold.
openjdk-8-doc set on hold.
openjdk-8-jdk set on hold.
openjdk-8-dbg set on hold.
openjdk-8-demo set on hold.
openjdk-8-jdk-headless set on hold.
openjdk-8-source set on hold.
openjdk-8-jre-dcevm set on hold.
openjdk-8-jre-zero set on hold.
-1

Have you tried:

  1. sudo apt-get remove '*jre*'
  2. sudo apt-get remove '*icedtea*'

These are just regex's that should match anything with "icedtea" or "jre" in the name.
Hope this helps!

5
  • I doubt that will work, at least when called from shell. The shell will interpret the asterisks as shell globs, and try to expand them. Depending on your setting, most likely it will try to expand them into a list of all files in the working directory that have the string jre (or icedtea) in their filename. Even if there are such files, it is very unlikely that their filenames will be exactly the names of the packages you want to remove. Jun 16, 2013 at 3:15
  • @JanHlavacek Oops. I will fix it. These commands work when called from an empty directory! ;)
    – BenjiWiebe
    Jun 17, 2013 at 13:20
  • @JanHlavacek They should work correctly now.
    – BenjiWiebe
    Jun 17, 2013 at 13:20
  • 2
    That depends on your shell, and perhaps on your specific setting. When I try to run them from an empty directory, the shell complains that it cannot find any match, and cannot therefore expand the glob. Another problem is that you are relying on the fact that there is no other completely unrelated package that has, by chance, the string jre in its name. While that seems to be the case in the current Debian repos, it may not be the best idea to rely on it, in the case someone packages the (fictional) program jrecode which converts between differet japanese character sets. Jun 17, 2013 at 21:43
  • I mean the original ones. The quoted ones work, but still see my other point. Jun 17, 2013 at 21:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .