1

I want to use jre-1_5_0_21 on my Fedora 14 box. Here's what's 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
java-1.6.0-openjdk-plugin-1.6.0.0-52.1.9.7.fc14.i686
java-1.6.0-openjdk-1.6.0.0-52.1.9.7.fc14.i686
java-1.5.0-gcj-1.5.0.0-34.fc14.i686
java_cup-0.11a-4.fc13.noarch
tzdata-java-2011d-3.fc14.noarch
$ 

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

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 [...]

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
LanceBaynes
  • 40,135
  • 97
  • 255
  • 351

2 Answers2

2

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
  • 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 'SO- stop being evil' 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 08 '11 at 18:58
0

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.

user unknown
  • 10,482
  • 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 1.5.0.0-34, not 1.5.0.21, 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