Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.
$ uname -a
Linux X51 3.0.0-12-generic #20-Ubuntu SMP Fri Oct 7 14:56:25 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux

$ java -version
java version "1.6.0_23"
OpenJDK Runtime Environment (IcedTea6 1.11pre) (6b23~pre11-0ubuntu1.11.10.2)
OpenJDK 64-Bit Server VM (build 20.0-b11, mixed mode)

I have above versions, which have important stable setup (for my own application):

  • Unfortunately i was working always with Java 1.6 as shown.
  • But now discovered that many-things are not working because of that version issue.
  • I want to remove the:

a) old java completely (safely)

b) switch to new, install openjdk-7 64-bit (safely)

Is it a better idea to simply apply apt-get remove openjdk*. ?

Or

what else would be smarter and safer way? (to avoid not losing many other dependencies just only to remove openjdk-6)

Follow up:

$ java -version
java version "1.7.0_09"
OpenJDK Runtime Environment (IcedTea7 2.3.3) (7u9-2.3.3-0ubuntu1~12.10.1)

$ sudo update-alternatives --config java
[sudo] password for sun: 
There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                            Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java   1071      auto mode
  1            /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java   1061      manual mode
  2            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java   1071      manual mode

Press enter to keep the current choice[*], or type selection number: 1
update-alternatives: using /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java to provide /usr/bin/java (java) in manual mode

$ java -version
java version "1.6.0_24"
OpenJDK Runtime Environment (IcedTea6 1.11.5) (6b24-1.11.5-0ubuntu1~12.10.1)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)
share|improve this question

1 Answer 1

up vote 3 down vote accepted

what else would be smarter and safer way? (to avoid not losing many other dependencies just only to remove openjdk-6)

The smartest way is to be backward-compatible and install both of them (Java 7 is still maturing, I believe.)

Install OpenJDK 7, and whatever else you need, and then use sudo update-alternatives --config java to show you the various available java binaries and their locations and select a default (invoked when you just type java).

This lets you still use Java 6 when necessary by simply calling it via the full path to the binary. Replace java with javac, etc. in update-alternatives and set those too.

When you determine that all your code/programs runs stable on 1.7 and want to get rid of 1.6, run dpkg --list | grep -i openjdk to find out what packages are installed on your system, before you run something like apt-get remove openjdk.*!!

share|improve this answer

Your Answer

 
discard

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.