Fedora Linux Support Community & Resources Center

Go Back   FedoraForum.org > Fedora 17/18 > Using Fedora
FedoraForum Search

Forgot Password? Join Us!

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 16th April 2012, 08:16 PM
foampile Offline
Registered User
 
Join Date: Jan 2012
Location: Washington, DC
Posts: 157
linuxfirefox
Question 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
Reply With Quote
  #2  
Old 16th April 2012, 08:50 PM
PabloTwo's Avatar
PabloTwo Online
"Registered User" T-Shirt Winner
 
Join Date: Mar 2007
Location: Seville, FL
Posts: 5,128
linuxchrome
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.
Reply With Quote
  #3  
Old 16th April 2012, 09:16 PM
foampile Offline
Registered User
 
Join Date: Jan 2012
Location: Washington, DC
Posts: 157
linuxfirefox
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
Reply With Quote
  #4  
Old 20th June 2012, 02:06 AM
foampile Offline
Registered User
 
Join Date: Jan 2012
Location: Washington, DC
Posts: 157
linuxfirefox
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
Reply With Quote
  #5  
Old 20th June 2012, 02:10 AM
PabloTwo's Avatar
PabloTwo Online
"Registered User" T-Shirt Winner
 
Join Date: Mar 2007
Location: Seville, FL
Posts: 5,128
linuxchrome
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.
Reply With Quote
  #6  
Old 20th June 2012, 02:14 AM
foampile Offline
Registered User
 
Join Date: Jan 2012
Location: Washington, DC
Posts: 157
linuxfirefox
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 ?
Reply With Quote
  #7  
Old 20th June 2012, 02:24 AM
PabloTwo's Avatar
PabloTwo Online
"Registered User" T-Shirt Winner
 
Join Date: Mar 2007
Location: Seville, FL
Posts: 5,128
linuxchrome
Re: pointing /usr/bin/java to different installations

Quote:
Originally Posted by foampile View Post
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.
Reply With Quote
  #8  
Old 20th June 2012, 02:30 AM
foampile Offline
Registered User
 
Join Date: Jan 2012
Location: Washington, DC
Posts: 157
linuxfirefox
Re: pointing /usr/bin/java to different installations

both are correct paths, that is why i am asking
Reply With Quote
  #9  
Old 20th June 2012, 02:49 AM
PabloTwo's Avatar
PabloTwo Online
"Registered User" T-Shirt Winner
 
Join Date: Mar 2007
Location: Seville, FL
Posts: 5,128
linuxchrome
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.
Reply With Quote
  #10  
Old 20th June 2012, 03:22 AM
foampile Offline
Registered User
 
Join Date: Jan 2012
Location: Washington, DC
Posts: 157
linuxfirefox
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
Reply With Quote
Reply

Tags
installations, or usr or bin or java, pointing

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
pointing device problem Shubh Hardware & Laptops 0 19th February 2012 03:02 PM
dir pointing to a non -existent location in fedora!! girish_rvd Using Fedora 0 27th January 2009 10:15 AM
Pointing a Satellite Dish Hobashira Wibble 2 17th April 2008 06:45 PM
desktop icon pointing to a lan machine robsmachine Servers & Networking 3 8th September 2006 12:04 AM


Current GMT-time: 17:33 (Friday, 24-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat