 |
 |
 |
 |
| Using Fedora General support for current versions. Ask questions about Fedora and it's software that do not belong in any other forum. |

16th April 2012, 08:16 PM
|
|
Registered User
|
|
Join Date: Jan 2012
Location: Washington, DC
Posts: 157

|
|
pointing /usr/bin/java to different installations
how do you change what the binary /usr/bin/java points to if you have different java installations, e.g. 1.6 and 1.7? how do you switch between the two?
thanks
|

16th April 2012, 08:50 PM
|
 |
"Registered User" T-Shirt Winner
|
|
Join Date: Mar 2007
Location: Seville, FL
Posts: 5,128

|
|
|
Re: pointing /usr/bin/java to different installations
This is what the "alternatives" command is for. If you have two or more java installs that have had an "alternatives" install, then you can use the alternatives command to switch/toggle which one to make the "default".
Code:
sudo alternatives --display java
will show you the alternatives installed java versions.
Code:
sudo alternatives --config java
will let you select which one to make the default.
You could also do a "yum install galternatives" to get a gui app for the alternatives command.
|

16th April 2012, 09:16 PM
|
|
Registered User
|
|
Join Date: Jan 2012
Location: Washington, DC
Posts: 157

|
|
|
Re: pointing /usr/bin/java to different installations
thanks, Pablo
---------- Post added at 08:16 PM ---------- Previous post was at 07:55 PM ----------
i got rid of all the old java installs, 1.6 and 5 so now i only have 7. when i ran display, it returned nothing. is this as designed? i was expecting to at least show me the one version i have installed
|

20th June 2012, 02:06 AM
|
|
Registered User
|
|
Join Date: Jan 2012
Location: Washington, DC
Posts: 157

|
|
|
Re: pointing /usr/bin/java to different installations
any idea why my latest installation of Oracle Java 7 in /usr/java/jdk1.7.0_03 does not appear under alternatives?
and does it make sense, once i somehow manage to stuff it in there, get rid of GCJ in /usr/lib, which only confuses Eclipse and doubt i need it?
thanks
Quote:
>>alternatives --display java
java - status is manual.
link currently points to /usr/lib/jvm/jre-1.5.0-gcj/bin/java
/usr/lib/jvm/jre-1.5.0-gcj/bin/java - priority 1500
slave jre: /usr/lib/jvm/jre-1.5.0-gcj
slave jre_exports: /usr/lib/jvm-exports/jre-1.5.0-gcj
slave keytool: /usr/lib/jvm/jre-1.5.0-gcj/bin/keytool
slave rmiregistry: /usr/lib/jvm/jre-1.5.0-gcj/bin/rmiregistry
Current `best' version is /usr/lib/jvm/jre-1.5.0-gcj/bin/java.
|
---------- Post added at 01:06 AM ---------- Previous post was at 12:53 AM ----------
in other words, if i installed my Oracle Java 7 with RPM and not alternatives --install, is there even a way to get it to appear under alternatives
|

20th June 2012, 02:10 AM
|
 |
"Registered User" T-Shirt Winner
|
|
Join Date: Mar 2007
Location: Seville, FL
Posts: 5,128

|
|
|
Re: pointing /usr/bin/java to different installations
Quote:
|
Originally Posted by foampile
any idea why my latest installation of Oracle Java 7 in /usr/java/jdk1.7.0_03 does not appear under alternatives?
|
Yes, because you didn't use the "alternatives --install" command to set it up as an alternative java.
Assuming I've got the correct path to the jdk1.7.0_03 java binary... try this: (fix the path to the binary if it's different).
Code:
sudo alternatives --install /usr/bin/java java /usr/java/jdk1.7.0_03/bin/java 1600
Then run the "alternatives --display java" command to confirm that it shows up. If it's there, then you can make it the default java with the..
Code:
sudo alternatives --config java
command.
|

20th June 2012, 02:14 AM
|
|
Registered User
|
|
Join Date: Jan 2012
Location: Washington, DC
Posts: 157

|
|
|
Re: pointing /usr/bin/java to different installations
thanks. what is 1600 ?
---------- Post added at 01:14 AM ---------- Previous post was at 01:12 AM ----------
and does it matter whether i use
/usr/java/jdk1.7.0_03/bin/java
or
/usr/java/jdk1.7.0_03/jre/bin/java ?
|

20th June 2012, 02:24 AM
|
 |
"Registered User" T-Shirt Winner
|
|
Join Date: Mar 2007
Location: Seville, FL
Posts: 5,128

|
|
|
Re: pointing /usr/bin/java to different installations
Quote:
Originally Posted by foampile
thanks. what is 1600 ?
|
"priority level". The format of the command I gave you is like so:
alternatives --install <symlink> <name> <path_to_binary> <priority_level>
See "man alternatives". I think 20,000 is the max priority level you can set. I chose 1600 because your other java was set to 1500, so the Oracle/Sun jdk will have a higher priority.
---------- Post added at 09:24 PM ---------- Previous post was at 09:17 PM ----------
Quote:
and does it matter whether i use
/usr/java/jdk1.7.0_03/bin/java
or
/usr/java/jdk1.7.0_03/jre/bin/java ?
|
Of course it matters. Use whatever is the correct path.
|

20th June 2012, 02:30 AM
|
|
Registered User
|
|
Join Date: Jan 2012
Location: Washington, DC
Posts: 157

|
|
|
Re: pointing /usr/bin/java to different installations
both are correct paths, that is why i am asking
|

20th June 2012, 02:49 AM
|
 |
"Registered User" T-Shirt Winner
|
|
Join Date: Mar 2007
Location: Seville, FL
Posts: 5,128

|
|
|
Re: pointing /usr/bin/java to different installations
Well, since I only install the JRE Sun package and never the JDK Sun package, I don't know how to advise you on that. You could check to see if on is just a symlink to the other first.
---------- Post added at 09:36 PM ---------- Previous post was at 09:34 PM ----------
Code:
ls -l /usr/java/jdk1.7.0_03/bin/java
ls -l /usr/java/jdk1.7.0_03/jre/bin/java
---------- Post added at 09:49 PM ---------- Previous post was at 09:36 PM ----------
Actually, you should be following this guide for F17 or this guide for F16. The target directory is a bit different than what I showed you, and it's actually how I installed my JRE package into alternatives. Though the commands I gave you may very well work. You can always check if you succeeded by using the "java -version" command and see what comes back at you.
Last edited by PabloTwo; 20th June 2012 at 02:52 AM.
|

20th June 2012, 03:22 AM
|
|
Registered User
|
|
Join Date: Jan 2012
Location: Washington, DC
Posts: 157

|
|
|
Re: pointing /usr/bin/java to different installations
JRE works fine so that Eclipse doesn't complain on startup. it is more specific, i.e. points to just the runtime env and not SDK, we'll see how it works. it is easy to change now that i know how to, if it turns i need to point to the more complete SDK lineup.
thanks
---------- Post added at 02:18 AM ---------- Previous post was at 01:59 AM ----------
hey, one more question. how do i get rid of the GCJ distro of Java altogether ?
---------- Post added at 02:22 AM ---------- Previous post was at 02:18 AM ----------
nvrmnd, i did it in Apper
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
Current GMT-time: 17:33 (Friday, 24-05-2013)
|
|
 |
 |
 |
 |
|
|