3

I am doing Java programming on Debian. By default Debian 6.x ships with libgcj JVM. On starting eclipse it shows a warning that this JVM is deprecated and may cause problems. For this reason I downloaded the JVM from Oracle's site and installed it.

However after installing the Oracle JVM the default JVM on system is still libgcj. When I type java -version I get following output -

java version "1.5.0" gij (GNU libgcj) version 4.4.5 

How should I remove this from my system? And after that how should I set the newly installed JVM to be the default one. This would involve two things -

  1. Setting the bin directory on system path.
  2. Making javaw the default program when a jar is double clicked.

I'm familiar with these tasks on Windows but not on Linux. Thanks.

2 Answers 2

3

Debian has a command that enables possibilities to choose a program from a list of programs that do something similar. The command update-alternatives sets links to default programs for various operations.

To choose a default java command from a list of installed JVMs one need to run as root command: update-alternatives --config java and choose the java edition to use.

If java is not registered (installed) in alternatives subsystem you need to install it by using update-alternatives --install "/usr/bin/java" "java" "/path/to/jdk" 1 .

From update-alternatives manual description of --install option:

--install link name path priority [--slave link name path]...

Add a group of alternatives to the system. link is the generic name for the master link, name is the name of its symlink in the alternatives directory, and path is the alternative being introduced for the master link. The arguments after --slave are the generic name, symlink name in the alternatives directory and the alternative path for a slave link. Zero or more --slave options, each followed by three arguments, may be specified. Note that the master alternative must exist or the call will fail. However if a slave alternative doesn't exist, the corresponding slave alternative link will simply not be installed (a warning will still be displayed). If some real file is installed where an alternative link has to be installed, it is kept unless --force is used.


edit summary: Answer edited to contain comments suggestions below by Manula Waidyanatha and Gilles - many thanks.

5
  • I tried it. I got the following output - There is only one alternative in link group java: /usr/bin/gij-4.4 Nothing to configure. Commented Aug 20, 2012 at 8:59
  • 1
    First you have to use sudo update-alternatives --install "/usr/bin/java" "java" "/path/to/jdk" 1 then use update-alternatives --config Commented Aug 20, 2012 at 9:00
  • @ManulaWaidyanatha Do you also happen to know how to uninstall libgcj? Commented Aug 20, 2012 at 9:20
  • did u try apt-get remove libgcj10. Commented Aug 20, 2012 at 9:28
  • 1
    Debian invented update-alternatives! Commented Aug 20, 2012 at 22:01
2

Unless you need Java 7, you don't need to go outside of Debian to get Java. Debian includes official Java in the sun-java6-* packages.

Install sun-java6-jdk

apt-get install sun-java6-jdk 

Remove gcj.

apt-get purge libgcj10 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.