Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use the command update-alternatives --config java

Tags:

java

debian

I am installing Apache Solr on Linux Debian (Squeeze). I have been instructed to install sun-java jdk 1st. Then am told that I should use the command sudo update-alternatives --config java to make sure that a particular java (sun-java) is the default runtime. Yet when I run this command I get:

There are 3 choices for the alternative java (providing /usr/bin/java).    Selection    Path                                      Priority   Status ------------------------------------------------------------ * 0            /usr/lib/jvm/java-6-openjdk/jre/bin/java   1061      auto mode   1            /usr/bin/gij-4.4                           1044      manual mode   2            /usr/lib/jvm/java-6-openjdk/jre/bin/java   1061      manual mode   3            /usr/lib/jvm/java-6-sun/jre/bin/java       63        manual mode  Press enter to keep the current choice[*], or type selection number: 

So which number should I select to have sun-java as the default runtime? Also, what exactly do th auto and manual modes mean? If I select 3 above and run the update-alternative command I receive the same output as above, again nothing seems to have changed except that the * is now in front of the 3, though it still reads manual mode.

Is there a way to confirm that what I have done is correct?

like image 346
user1680916 Avatar asked Oct 08 '12 18:10

user1680916


People also ask

What is update-alternatives java?

update-java-alternatives is a program to update alternatives for jre/jdk installations. update-alternatives is a symbolic link management system for linux (I'm sure there is little news here). You can, and really should, use both update-java-alternatives and update-alternatives together.

What is update-alternatives command?

update-alternatives creates, removes, maintains and displays information about the symbolic links comprising the Debian alternatives system. It is possible for several programs fulfilling the same or similar functions to be installed on a single system at the same time.

Where can I find java alternatives in Linux?

To see the full alternatives (including slaves), use the --display option: > sudo update-alternatives --display java java - auto mode link best version is /usr/lib64/jvm/jre-1.8.


1 Answers

You will notice a big change when selecting options if you type in "java -version" after doing so. So if you run update-alternatives --config java and select option 3, you will be using the Sun implementation.
Also, with regards to auto vs manual mode, making a selection should take it out of auto mode per this page stating:

When using the --config option, alternatives will list all of the choices for the link group of which given name is the master link. You will then be prompted for which of the choices to use for the link group. Once you make a change, the link group will no longer be in auto mode. You will need to use the --auto option in order to return to the automatic state.

And I believe auto mode is set when you install the first/only JRE/JDK.

like image 125
Jordan Denison Avatar answered Oct 20 '22 15:10

Jordan Denison