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 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
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"?

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

Thanks!

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
add comment

2 Answers

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
add comment

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 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
add comment

Your Answer

 
discard

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.