CentOS Icon CentOS Logo
CentOS Text
   
  
www.centos.org Forum Index
   CentOS 4 - Application & Software Support
  Adding Java 1.5.0_06 to alternatives system?

 

 Bottom   Previous Topic   Next Topic
  •  Rate Thread
      Rate this Thread
      Excellent
      Good
      Average
      Bad
      Terrible
Poster Thread Rated:  1 Votes
  •  rje_nc
      rje_nc
Adding Java 1.5.0_06 to alternatives system?
#1
Regular Board Member
Joined: 2004/12/25
From Greensboro, NC
Posts: 74
Can anyone give me an example on how to use the alternatives system to link the new version of java I have just installed?

I just installed the Sun JDK v1.5.0_06 and it is installed in /usr/java/jdk1.5.0_06. I want to add this version to the alternatives system and set the priority so the jre in this directory is called by default.

I cannot figure out how to add this version of Java to the RH Alternatives System. I have read the man pages and several links that just seem to be a rehash of the man page. I need to see and example of adding another application to the system and how I configure it to be the default choice.

Any examples or a point to a link with examples on how this works would be appreciated.

Thanks...

Bob
Posted on: 2006/1/27 20:21
Create PDF from Post Print
Top
  •  Lenard
      Lenard
Re: Adding Java 1.5.0_06 to alternatives system?
#2
Professional Board Member
Joined: 2005/11/29
From Indiana
Posts: 2283
Reconfiguring CentOS 4's default Java configuration. This is done as root or equivalent and is for jre adjust for jdk where needed;

First remove /var/lib/alternatives/java file by typing;

rm /var/lib/alternatives/java

When asked press the 'y' key,

Now to create the new (corrected) alternatives file for java type the following commands as root (modify for jdk as needed);

/usr/sbin/alternatives --install /usr/bin/java java /usr/lib/jvm/jre-1.4.2-gcj/bin/java 1

/usr/sbin/alternatives --install /usr/bin/java java /usr/java/j2re1.5.0_06/bin/java 2

/usr/sbin/alternatives --config java

You should now see for example:

There are 2 programs which provide 'java'.

Selection Command
-----------------------------------------------
1 /usr/lib/jvm/jre-1.4.2-gcj/bin/java
*+ 2 /usr/java/j2re1.5.0_06/bin/java

Enter to keep the current selection[+], or type selection number:

Type: <choose 1 or 2>

In the example above java is already configured correctly [*+ 2] to
use Sun's Java, no changes are needed, just press the Enter key here.
If you have been following the instructions then you should have
the same results (version numbers may be sightly different).

Now type; /usr/sbin/alternatives --display java

You should see for example;

java - status is manual.
link currently points to /usr/java/j2re1.5.0_06/bin/java
/usr/lib/jvm/jre-1.4.2-gcj/bin/java - priority 1
/usr/java/j2re1.5.0_06/bin/java - priority 2
Current `best' version is /usr/java/j2re1.5.0_06/bin/java.

Next you might want to create (or edit) /etc/profile.d/java.sh
file, example below;

export JAVA_HOME="/usr/java/jre1.5.0_06/bin"
export JAVA_PATH="$JAVA_HOME"
export PATH="$PATH:$JAVA_HOME"

When done creating or editing the file type;

source /etc/profile.d/java.sh

Now any user root or other wise should be able to use the command;

which java

and the results should read something like;

/usr/java/jre1.5.0_06/bin/java

Also any user root or other wize should be able to use the command;

java -version

and the results should read something like;

java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)


That's it, all done.
_________________
CentOS: The Sysadmins choice
Congratulations NedSlider
Posted on: 2006/1/28 10:21
Create PDF from Post Print
Top
  •  rje_nc
      rje_nc
Re: Adding Java 1.5.0_06 to alternatives system?
#3
Regular Board Member
Joined: 2004/12/25
From Greensboro, NC
Posts: 74
Thanks for the detailed instructions. I'll give it a try when I get to work on Monday.

Bob
Posted on: 2006/1/30 0:41
Create PDF from Post Print
Top
  •  machalla
      machalla
Re: Adding Java 1.5.0_06 to alternatives system?
#4
Newbie
Joined: 2006/1/31
From
Posts: 4
Many thanks Lenard for the detailed instructions. I have just installed the latest jre as per your detailed instructions on a new Centos 4.2 install with not a problem. All is working fine for me so far.

Thanks again.
Posted on: 2006/1/31 12:35
Create PDF from Post Print
Top
  •  1jan2006
      1jan2006
Re: Adding Java 1.5.0_06 to alternatives system?
#5
Newbie
Joined: 2006/3/1
From
Posts: 3
I did accordingly and it seems alright till the last step 'java -version' it says 'command not found'

I have also installed openoffice2.0.1 and it works fine and also another application (cmap) that also has jre directories on their own. But I could not make the JRE working universal in centos4.2 so that I could run radrails (radrails.org).

Thanks!
Posted on: 2006/3/1 8:55
Create PDF from Post Print
Top
  •  Lenard
      Lenard
Re: Adding Java 1.5.0_06 to alternatives system?
#6
Professional Board Member
Joined: 2005/11/29
From Indiana
Posts: 2283
Show the output from the commands;

$PATH

/usr/sbin/alternatives --display java

cat /etc/profile.d/java.sh
_________________
CentOS: The Sysadmins choice
Congratulations NedSlider
Posted on: 2006/3/1 10:59
Create PDF from Post Print
Top
  •  1jan2006
      1jan2006
Re: Adding Java 1.5.0_06 to alternatives system?
#7
Newbie
Joined: 2006/3/1
From
Posts: 3
1. $ $PATH
bash: /usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/java/jre1.5.0_06/bin:/home/drbista/bin:/usr/java/jre1.5.0_06/bin: No such file or directory


2. $ /usr/sbin/alternatives --display java
java - status is manual.
link currently points to /usr/java/j2re1.5.0_06/bin/java
/usr/lib/jvm/jre-1.4.2-gcj/bin/java - priority 1
/usr/java/j2re1.5.0_06/bin/java - priority 2
Current `best' version is /usr/java/j2re1.5.0_06/bin/java.

3. $ cat /etc/profile.d/java.sh
export JAVA_HOME="/usr/java/jre1.5.0_06/bin"
export JAVA_PATH="$JAVA_HOME"
export PATH="$PATH:$JAVA_HOME"
Posted on: 2006/3/2 9:11
Create PDF from Post Print
Top
  •  Lenard
      Lenard
Re: Adding Java 1.5.0_06 to alternatives system?
#8
Professional Board Member
Joined: 2005/11/29
From Indiana
Posts: 2283
Everything looks normal, try specifing the full path;

/usr/java/j2re1.5.0_06/bin/java -version
_________________
CentOS: The Sysadmins choice
Congratulations NedSlider
Posted on: 2006/3/2 12:29
Create PDF from Post Print
Top
  •  1jan2006
      1jan2006
Re: Adding Java 1.5.0_06 to alternatives system?
#9
Newbie
Joined: 2006/3/1
From
Posts: 3
The output is still the same:

$ /usr/java/j2re1.5.0_06/bin/java -version
bash: /usr/java/j2re1.5.0_06/bin/java: No such file or directory
Posted on: 2006/3/2 17:52
Create PDF from Post Print
Top
  •  Lenard
      Lenard
Re: Adding Java 1.5.0_06 to alternatives system?
#10
Professional Board Member
Joined: 2005/11/29
From Indiana
Posts: 2283
OK, check the directory you should have some files in /usr/java/jre1.5.0_06/bin/ directory, for example;

$ ls -al /usr/java/jre1.5.0_06/bin/
total 1332
drwxr-xr-x 2 root root 4096 Jan 24 12:43 .
drwxr-xr-x 7 root root 4096 Jan 24 12:43 ..
-rwxr-xr-x 1 root root 4153 Nov 10 16:47 ControlPanel
-rwxr-xr-x 1 root root 63984 Nov 10 17:18 java
-rwxr-xr-x 1 root root 17567 Nov 10 17:18 java_vm
-rwxr-xr-x 1 root root 163997 Nov 10 17:18 javaws
-rwxr-xr-x 1 root root 71848 Nov 10 17:18 keytool
-rwxr-xr-x 1 root root 71848 Nov 10 17:18 kinit
-rwxr-xr-x 1 root root 71848 Nov 10 17:18 klist
-rwxr-xr-x 1 root root 71848 Nov 10 17:18 ktab
-rwxr-xr-x 1 root root 71848 Nov 10 17:18 orbd
-rwxr-xr-x 1 root root 71848 Nov 10 17:18 pack200
-rwxr-xr-x 1 root root 71856 Nov 10 17:18 policytool
-rwxr-xr-x 1 root root 71848 Nov 10 17:18 rmid
-rwxr-xr-x 1 root root 71848 Nov 10 17:18 rmiregistry
-rwxr-xr-x 1 root root 71848 Nov 10 17:18 servertool
-rwxr-xr-x 1 root root 71848 Nov 10 17:18 tnameserv
-rwxr-xr-x 1 root root 221893 Nov 10 17:18 unpack200

And you shold have a hidden .java directory for each user.
_________________
CentOS: The Sysadmins choice
Congratulations NedSlider
Posted on: 2006/3/2 18:39
Create PDF from Post Print
Top
  •  victorgh
      victorgh
Re: Adding Java 1.5.0_06 to alternatives system?
#11
Newbie
Joined: 2006/4/6
From Oklahoma
Posts: 1
Lenard - Thanks for the great instructions! They worked perfectly.
Posted on: 2006/4/6 13:54
Create PDF from Post Print
Top
  •  renagade8
      renagade8
Re: Adding Java 1.5.0_06 to alternatives system?
#12
Newbie
Joined: 2006/6/3
From Pennsylvania
Posts: 1
Would I do the same thing for javac?
Posted on: 2006/6/6 22:11
Create PDF from Post Print
Top
 Top   Previous Topic   Next Topic

 


 You cannot start a new topic.
 You can view topic.
 You cannot reply to posts.
 You cannot edit your posts.
 You cannot delete your posts.
 You cannot add new polls.
 You cannot vote in polls.
 You cannot attach files to posts.
 You cannot post without approval.




"Linux" is a registered trademark of Linus Torvalds. | All other trademarks are property of their respective owners. | All other content is Copyright @ 2004-2009 by the CentOS Project or "each individual contributor (forums, comments, etc.) unless otherwise assigned".| Theme based on a theme by 7dana.com