LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Redhat 5.5 and java -version (https://www.linuxquestions.org/questions/linux-general-1/redhat-5-5-and-java-version-867215/)

ajslinux 03-08-2011 09:05 AM

Redhat 5.5 and java -version
 
Hi All,

I am working on a new Redhat Server (RHEL 5.5). It has java version "1.4.2" installed on it. I have installed
jre1.6.0_24 on it but "java -version" is still showing the old java version (1.4.2). How can point "java -version" to the new install?

Thanks for your help!
Ajay

centosboy 03-08-2011 09:17 AM

Quote:

Originally Posted by ajslinux (Post 4282807)
Hi All,

I am working on a new Redhat Server (RHEL 5.5). It has java version "1.4.2" installed on it. I have installed
jre1.6.0_24 on it but "java -version" is still showing the old java version (1.4.2). How can point "java -version" to the new install?

Thanks for your help!
Ajay

where is your java path??

Code:


which java


you can either create a symlink from your new jreinstall path executable to your standard java path (/usr/bin/java, but you would have to rename /usr/bin/java first) OR add the path for the new jre to /etc/profile or your .bash_profile etc or just switch the paths from the old java to the new jre install.

szboardstretcher 03-08-2011 09:18 AM

The important question here is - "Is anything going to break, if i tell you how, because some program will need that old java version?"

PrinceCruise 03-08-2011 09:22 AM

Hi,

When you run java -version, the system searches for the PATH for the installed java.
So update the path, IMO it should work :

#export PATH=/new/path of java/wherever/it/is:$PATH

Now try # java -version.

ajslinux 03-08-2011 09:26 AM

Thanks for your responses. I was able to do this, here is the solution:

# java -version
java version "1.4.2"
gij (GNU libgcj) version 4.1.2 20080704 (Red Hat 4.1.2-48)
# which java
/usr/bin/java
# ls -ld /usr/bin/java
lrwxrwxrwx 1 root root 22 Jan 11 04:55 /usr/bin/java -> /etc/alternatives/java
# rm /usr/bin/java
rm: remove symbolic link `/usr/bin/java'? y
# ln -s /usr/java/jre1.6.0_24/bin/java /usr/bin/java
# ls -ld /usr/bin/java
lrwxrwxrwx 1 root root 30 Mar 8 10:20 /usr/bin/java -> /usr/java/jre1.6.0_24/bin/java
# java -version
java version "1.6.0_24"
Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02, mixed mode)

PrinceCruise 03-08-2011 09:28 AM

cool.

centosboy 03-08-2011 09:58 AM

yayyy

szboardstretcher 03-08-2011 10:04 AM

Keep in mind that a LOT of java programs like you to:

export JAVA_HOME=/wherever/java/bin/

In your shell environment

knudfl 03-08-2011 12:05 PM

The standard set up for EL5 is :

1)
# /usr/sbin/alternatives --install /usr/bin/java java /usr/java/jre1.6.0_24/bin/java 2

2) # /usr/sbin/alternatives --config java

.


All times are GMT -5. The time now is 02:20 AM.