6

I had installed sun-java, but I want to revert back to OpenJDK 7. I was trying to re-install from the terminal using the command sudo apt-get install openjdk-7-jre, same from Synaptic and Software Center, but it does not work.

I try to use the command java -version and then I get a message like The java program can be found on follow packages» open-7-jre-headless

So, I tried to install it, but they ARE installed on my system...

I do no want format my PC just for Java.

Thanks.

Kevin Bowen
  • 19,615
  • 55
  • 79
  • 83
yyeshua
  • 61
  • What do you mean "does not work"? Can you add the output of apt-get install openjdk-7-jre to your question? – Iain Lane Jan 10 '12 at 20:58

3 Answers3

3

Use

 update-java-alternatives 

to switch between different implementations without removing or reinstalling and downloading packages.

user unknown
  • 6,507
2

In order to switch between installed Java versions, you can use the update alternatives command.

  • To obtain a list of the installed Java packages on a system, run the following command from the terminal(Ctrl-Alt-t):

    sudo update-alternatives --config java
    

    This will give a list output similar to the following:

    There are 4 choices for the alternative java (providing /usr/bin/java).
       Selection    Path                                           Priority   Status
      ------------------------------------------------------------
      0            /usr/lib/jvm/java-7-oracle/jre/bin/java         1070      auto mode
      1            /usr/lib/jvm/java-7-openjdk-i386/jre/bin/java   1051      manual mode
    * 2            /usr/lib/jvm/java-7-oracle/jre/bin/java         1069      manual mode
    Press enter to keep the current choice[*], or type selection number: 
    

In this particular case, the Oracle Java 7 version is the current default(indicated by the asterisk).

In order to switch to the OpenJDK version, you would select option 1 at the prompt and press the Enter key.

You will now be running the OpenJDK 7 version.

No other changes will be needed to switch your Java versions.

Kevin Bowen
  • 19,615
  • 55
  • 79
  • 83
0

If you want to eliminate Sun Java altogether...

You can use dpkg-query -l *sun-java* to see the sun-java related packages that are installed. You can use sudo apt-get purge sun-java, etc., with the names of the package(s) to get rid of them.

If OpenJDK is already installed, that's great. Hopefully it'll just work from there. If not, sudo apt-get update && sudo apt-get upgrade might get you figured out.

If it still doesn't work, try repeating the package removal/purging process above for OpenJDK and re-installing it to start from scratch.

Gary
  • 3,914