Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

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.

share|improve this answer
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. –  Kshitiz Sharma Aug 20 '12 at 8:59
First you have to use sudo update-alternatives --install "/usr/bin/java" "java" "/path/to/jdk" 1 then use update-alternatives --config –  Manula Waidyanatha Aug 20 '12 at 9:00
@ManulaWaidyanatha Thanks. That works. –  Kshitiz Sharma Aug 20 '12 at 9:17
@ManulaWaidyanatha Do you also happen to know how to uninstall libgcj? –  Kshitiz Sharma Aug 20 '12 at 9:20
Debian invented update-alternatives! –  Gilles Aug 20 '12 at 22:01
show 1 more comment

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
share|improve this answer
add comment

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.