LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   [RHEL 5] A question about multiple Java (https://www.linuxquestions.org/questions/linux-software-2/%5Brhel-5%5D-a-question-about-multiple-java-4175510049/)

thomas2004ch 07-04-2014 12:18 AM

[RHEL 5] A question about multiple Java
 
Hi,

As I run 'java -version', I got
Code:

# java -version
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)

This means the active Java version is 1.7.0_45.

But as I run 'yum list installed |grep java', I got:
Code:

# yum list installed |grep java
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
glassfish-javamail.noarch          1.4.5-1.redhat_1.ep6.el5            installed
java-1.4.2-gcj-compat.x86_64      1.4.2.0-40jpp.115                  installed
java-1.7.0-oracle.x86_64          1:1.7.0.51-1jpp.1.el5_10            installed
java-1.7.0-oracle-devel.x86_64    1:1.7.0.51-1jpp.1.el5_10            installed
javassist-eap6.noarch              3.18.1-1.GA_redhat_1.1.ep6.el5      installed
tzdata-java.x86_64                2014e-1.el5                        installed

Here one can see the Java 1.7.0_51 is installed, not the 1.7.0_45.

As I run 'sudo update-alternatives --config java', I got
Code:

]# sudo update-alternatives --config java

There are 2 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
*+ 1          /usr/lib/jvm/jre-1.7.0-oracle.x86_64/bin/java
  2          /usr/lib/jvm/jre-1.4.2-gcj/bin/java

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


As I run '/usr/lib/jvm/jre-1.7.0-oracle.x86_64/bin/java -version', I got:
Code:

# /usr/lib/jvm/jre-1.7.0-oracle.x86_64/bin/java -version
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)

This means the 1.7.0_51 is installed.

How can I remove the 1.7.0_45?

MensaWater 07-05-2014 03:52 PM

Type "which java" to find out the path of the java binary on which you originally ran the version command.

By default on RHEL that would normally be /usr/bin/java which is a symbolic link created by alternatives to whichever package is installed.

Run "ls -l <pathto>/java" on whichever java binary and path is returned by the "which" command.

It it were doing the default RHEL setup that should return something like:
lrwxrwxrwx 1 root root 22 Apr 6 2009 /usr/bin/java -> /etc/alternatives/java

That shows /usr/bin/java is a symbolic link and that the file it is linked to is /etc/alternatives/java

Note that /etc/alternatives/java is usually itself another symbolic link so doing ls -l on the one shown in example confirms that
lrwxrwxrwx 1 root root 39 Aug 8 2010 /etc/alternatives/java -> /usr/lib/jvm/jre-1.6.0-openjdk/bin/java

However in your setup I suspect that:

EITHER "which" is NOT pointing to /usr/bin/java
This would be because your $PATH variable is finding a "java" somewhere setup by your environment profile, .bashrc or other setup file in a directory specified in $PATH before /usr/bin (e.g. /bin, /usr/local/bin, .) or because there is no java in /usr/bin so it is finding one after the /usr/bin in $PATH.

OR /usr/bin/java is NOT linked to /etc/alternatives but rather to some other installation of Java.
It is possible to install Java by downloading the bundle (or even just the binary) from somewhere else and putting it on your system. If /usr/bin/java is NOT a link then it was likely hard copied binary to that location by someone. If it is a link you need to go down the tree of links to determine where the real binary is. Once you find that you can type "rpm -qf <pathto>/java" to see what RPM installed it. If no RPM installed it then it may have been installed directly by copy from another system or by download of the bundle from someplace such as the Oracle Java site.

Note: Rather than removing the first Java you found (with the "which" above) you might want to make a copy of it then overwrite the original with a link to the correct location. Some applications will fail with minor variations in Java version and you'd want to be able to back out quickly if you saw this as an issue.


All times are GMT -5. The time now is 11:51 AM.