Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to install Java 7 onto my Ubuntu machine through apt-get. I'm issuing the to install using apt-get:

sudo apt-get openjdk-7-jre

apt-get claims a successful install, but I cannot appear to make use of OpenJDK 7. Note: I have also tried headless version and gotten similar results.

I'm a complete novice at Linux but comparing to OpenJDK 6 JRE which I have installed, there should be a java file at the ./jre/bin directory. I.e: A comparison of my OpenJDK 6 and 7 directories.

OpenJDK 6:

root/bin/$ pwd
root/bin/$ ll
total 464
drwxr-xr-x 2 root root  4096 Dec 25 17:28 ./
drwxr-xr-x 5 root root  4096 Dec 19 22:01 ../
-rwxr-xr-x 1 root root   757 Jul  2 01:38 itweb-settings*
-rwxr-xr-x 1 root root 39480 Nov 16 17:28 java*
-rwxr-xr-x 1 root root  1260 Jul  2 01:38 javaws*
-rwxr-xr-x 1 root root 39472 Nov 16 17:28 keytool*
-rwxr-xr-x 1 root root 39552 Nov 16 17:28 orbd*
-rwxr-xr-x 1 root root 39552 Nov 16 17:28 pack200*
-rwxr-xr-x 1 root root 39480 Nov 16 17:28 policytool*
-rwxr-xr-x 1 root root 39472 Nov 16 17:28 rmid*
-rwxr-xr-x 1 root root 39480 Nov 16 17:28 rmiregistry*
-rwxr-xr-x 1 root root 39480 Nov 16 17:28 servertool*
-rwxr-xr-x 1 root root 39560 Nov 16 17:28 tnameserv*
-rwxr-xr-x 1 root root 87280 Nov 16 17:28 unpack200*

OpenJDK 7:

root/bin/$ pwd
root/bin/$ ll
total 16
drwxr-xr-x 2 root root 4096 Dec 25 17:33 ./
drwxr-xr-x 5 root root 4096 Dec 25 17:33 ../
-rwxr-xr-x 1 root root 6360 Jul 16 03:46 policytool*

If this is correct, I am unsure of how to proceed to set Java 7 to be my default Java. If this is incorrect, I am unsure of how to correct this. I have attempted uninstalling and reinstalling with similar results.

EDIT: The output of following commands.

The output of java -version after installation:

root/~/$ java -version
java version "1.6.0_27"
OpenJDK Runtime Environment (IcedTea6 1.12.6) (6b27-1.12.6-1ubuntu0.12.04.4)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)

The output of dpkg -S $(type java | awk '{print $3}') after installation:

root/bin/$ hash -r; dpkg -S $(type java | awk '{print $3}')
dpkg-query: no path found matching pattern /usr/bin/java.
root/bin/$ ll /usr/bin/java
lrwxrwxrwx 1 root root 22 Nov 19 13:40 /usr/bin/java -> /etc/alternatives/java*

The output for update-alternatives:

root/bin/$ update-alternatives --display java
java - auto mode
  link currently points to /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java
/usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java - priority 1061
  slave java.1.gz: /usr/lib/jvm/java-6-openjdk-amd64/jre/man/man1/java.1.gz
Current 'best' version is '/usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java'.

After uninstalling openjdk-6-jre

root/~/$ java -version
The program 'java' can be found in the following packages:
 * default-jre
 * gcj-4.6-jre-headless
 * openjdk-6-jre-headless
 * gcj-4.5-jre-headless
 * openjdk-7-jre-headless
Try: apt-get install <selected package>

I then attempted to install Java 7 using apt-get install openjdk-7-jre but I am now back at the beginning; With Java 6 installed and Java 7 incorrectly installed.

share|improve this question
@Braiam: Edited again. It says no found pattern but there is definitely a /usr/bin/java file. – Hopeful Llama Dec 25 '13 at 18:35
How about update-alternatives --display java? – Braiam Dec 25 '13 at 18:39
You understand the differences b/w OpenJDK and Sun's Java? – slm Dec 25 '13 at 22:26

Apparently you have both java 6 and 7 installed. The easy way to fix this situation could be removing java 6 if you don't need it:

sudo apt-get autoremove 'openjdk-6-jre*'
share|improve this answer
I tried to the uninstall of Java 6, but it failed to find Java and recommended packages for me to install. Seems that Java 7 isn't installed. – Hopeful Llama Dec 25 '13 at 19:44
Could you edit your question and add the output? – Braiam Dec 25 '13 at 19:48
up vote 0 down vote accepted

Looking at the file listing at Ubuntu's package file listing, what is happening is actually expected behaviour, so I'm guessing maybe that the OpenJDK 7 JRE in the apt-get repo isn't intended for command line Linux distro's?

I've instead opted to install Oracle's Java 7 JDK/JRE as here.

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.