LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-04-2014, 12:18 AM   #1
thomas2004ch
Member
 
Registered: Aug 2009
Posts: 539

Rep: Reputation: 33
[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?
 
Old 07-05-2014, 03:52 PM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
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.

Last edited by MensaWater; 07-07-2014 at 07:38 AM.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
multiple shell scripts in multiple environments - quick question mpc8250 Linux - Newbie 2 01-16-2013 04:13 PM
Bash Question(for loop): How to Zip multiple files under multiple directories Znrall Linux - General 2 08-01-2012 01:52 PM
Question about multiple writes from multiple processes rainman1985_2010 Programming 3 10-08-2010 02:39 PM
Yet another java classpath question --- java.lang.NoClassDefFoundError Jama raequin Programming 1 12-29-2009 01:04 PM
java 1.5 in RHEL 5 davender84 Linux - General 1 06-17-2009 08:11 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration