Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to use jre-1_5_0_21 on my Fedora 14 box. Here's whats installed on my PC:

$ update-alternatives --config java

There are 2 programs which provide 'java'.

  Selection    Command
*+ 1           /usr/lib/jvm/jre-1.6.0-openjdk/bin/java
   2           /usr/lib/jvm/jre-1.5.0-gcj/bin/java

Enter to keep the current selection[+], or type selection number: 1
failed to create /var/lib/alternatives/java.new: Permission denied

rpm -qa

$ rpm -qa | grep -i java

How can I have several versions of java installed on my PC, and selecting it by: "update-alternatives --config java"?

UPDATE: so like when having several php versions on a webserver, I need to have several versions of JAVA, and it would be a practical thing to switch between the versions with "update-alternatives" then restart the webbrowser -> then the applet, that needs previous version of java [...] would start simply [...]


share|improve this question
BTW: It's spelled "Java". That is a name, not an abbreviation... – EricSchaefer Apr 28 '11 at 5:16
FYI, I still don't understand what you're getting at. You already have two versions of Java, and can choose the default one by calling sudo update-alternatives …. Are you looking for a place to download other versions? – Gilles Apr 29 '11 at 21:12
up vote 3 down vote accepted

If you just want to start a program with a specific Java implementation, give the full path to the java interpreter:

/usr/lib/jvm/jre-1.6.0-openjdk/bin/java my-app.jar

If you want to change the default interpreter, you just need to run update-alternatives as root:

sudo update-alternatives --config java
share|improve this answer
that's NOT what I asked. – LanceBaynes Apr 28 '11 at 15:39
@LanceBaynes: It's what you asked, it may not be what you meant to ask. If that's not what you meant to ask, edit your question to make it clearer (or ask a new question if that would be too big an edit). – Gilles Apr 28 '11 at 15:52
It's just because a program requires an older java version, and my purpose/question is that can I have several versions of java installed, and switch between them with a command? (ok, the command is ok: update-alternatives, but how to have several versions of java under Fedora?) – LanceBaynes May 8 '11 at 18:58

The important message is: 'failed to create /var/lib/alternatives/java.new: Permission denied'

 sudo update-alternatives --config java

so you need sudo, as Gilles suggested, without emphasis, and with a confusing statement about working around the alternatives-system.

share|improve this answer
that's NOT what I asked. – LanceBaynes Apr 28 '11 at 15:39
Well, for JRE-1.5 you have to choose 2, not 1, of course, which will lead to the same 'permission denied' answer, but JRE is, not, which raises the question, why you need that minor-minor-version-number. Most of the time, you choose between 1.6 or 1.5, but for each of them, you would use the most current release. Except you want to tackle a specific error, which is only present in one older version, but then you need to emphasize, wheter you mean gcj-, sun-jre, ibm- or someones else JRE, 32- or 64bit, Linux, Solaris, BSD or ... . – user unknown Apr 28 '11 at 17:34

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.