-1

I need to uninstall Java jdk1.6.0.27 from RHEL 5.7 and then install another version jre-7u40-linux-x64.rpm. The firs thing I did was to find out the current java version installed using the java -version command and the output is "java version "1.6.0_27"". After that I tried to check the previews version of java with the command:

rpm -qi jdk

The output is "package jdk is not installed" After installing the package jre-7u40-linux-x64.rpm in the /usr/java directory there are two java packages. The output of the ls command on /usr/java is: default jdk1.6.0_27 jre1.7.0_40 jre-7u40-linux-x64.rpm latest.

when I run the command "alternatives --config java" the output is:

*+ 1   /usr/java/latest/bin/java

I am new to RHEL and I need some help to understand the situation.

To conclude I need some help to remove the previews jdk1.6.0.27 and to install jre1.7.0_40.

Thank you in advance for your help! Best regards, Claudio

Yazan
  • 6,074
  • 1
  • 19
  • 33
Claude
  • 1
  • 4
  • i think you have missing a command "alternatives --install" check this question http://stackoverflow.com/questions/20901442/how-to-install-jdk-in-centos – Yazan Nov 03 '14 at 10:19
  • In fact as I said before I had jdk1.6.0_27 installed. I run the command rpm –e jdk to uninstalled that and after that i did rpm –ivh jdk-7u25-linux-x64.rpm and alternatives --install /usr/bin/java java /usr/java/latest/bin/java 301 and after that alternatives --config java. At the and the java -version returns the old version 1.6.0_27. – Claude Nov 03 '14 at 10:33
  • Is /usr/java/latest a symlink? Can you delete it and make a new symlink to the root of the 1.7 install? – Rup Nov 03 '14 at 10:35
  • ok alternatives --install is not mentioned in your question, i thought you did not do it, anyways, uninstalling is not a big deal, as you will config Java to the new installation, thats what i think, so focus on installing desired java or even extract from a .gz or tar file, then --install and --config it. – Yazan Nov 03 '14 at 10:36
  • Both commands rpm –qi jdk and rpm –e jdk output is: error: package jdk is not installed – Claude Nov 03 '14 at 10:36
  • Thanks Rup. Can you be more specific because I am new and I don't understand what your saying. – Claude Nov 03 '14 at 10:38
  • To identify the package, pick a file that's in it e.g. `/usr/java/jdk1.6.0_27/bin/java` and run `rpm -q -f /usr/java/jdk1.6.0_27/bin/java` – Rup Nov 03 '14 at 10:38
  • Dear Yazan. I have downloaded jre-7u40-linux-x64.rpm and installed it. – Claude Nov 03 '14 at 10:39
  • `cd /usr/java` then `ls -la` Does the line with `latest` in it start with an `l` and look something like `latest -> /usr/java/jdk1.6.0_27`? If so then it's a symbolic link to that directory, not a directory in itself. You can change this by e.g. `rm -f latest` to remove it, then `ln -s /usr/java/jre1.7.0_40 latest` to make a new symlink to the 1.7 version. That may not be the best way to update, but it might play OK with alternatives. – Rup Nov 03 '14 at 10:40
  • Dear Rup. The command rpm -q -f /usr/java/jdk1.6.0_27/bin/java output is file /...../bin/java is not ouwned by any package – Claude Nov 03 '14 at 10:42
  • Dear Rup when I run ls the output is:default jdk1.6.0_27 jre1.7.0_40 jre-7u40-linux-x64.rpm(the rpm file) latest. that is all – Claude Nov 03 '14 at 10:45

2 Answers2

0

First, find out your real java executable. Start with

which java

This is going to give you some response such as:

/usr/bin/java

Next, do

ls -l /usr/bin/java 

(Or whatever it returned).

It will probably write something like:

/usr/bin/java -> /etc/alternatives/java

Do the same for whatever is pointed to by the arrow, until finally, when you do ls -l on it, there is no arrow.

Then, for that particular file, find out which rpm provides it by using

rpm -q -f <full path of the file you found>

It should tell you which package it belongs to, and then you can uninstall that.

However, if the rpm command returns The file ... is not owned by..., then your Java has not been installed using an rpm. It may have been installed manually by someone in the past. This makes uninstalling it a lot more problematic.

RealSkeptic
  • 33,993
  • 7
  • 53
  • 79
  • Thank you RealSkeptic. When I run Which java it returns: /usr/java/jdk1.6.0_27/bin/java. After running the command ls -l /usr/java/jdk1.6.0_27/bin/java it returns: – Claude Nov 03 '14 at 10:50
  • No arrow, so that's the file you should query with `rpm -q -f`. – RealSkeptic Nov 03 '14 at 10:52
  • Yes there is no arrow in the line – Claude Nov 03 '14 at 10:54
  • after running the rpm -q -f /usr/java/jdk1.6.0_27/bin/java the output is file /usr/java/jdk1.6.0_27/bin/java is not owned by any package – Claude Nov 03 '14 at 10:56
  • @Claude you ran the wrong command, RealSkrptic asked to run this `ls -l /usr/bin/java ` not `ls -l /usr/java/jdk1.6.0_27/bin/java` – Yazan Nov 03 '14 at 10:56
  • @Yazan, no, actually I told him to check what `which java` gives him. As it did not return `/usr/bin/java` but rather the direct file, he did the right thing. – RealSkeptic Nov 03 '14 at 10:57
  • Oh sorry. now I have a different result.It returns /usr/java/default/bin/java – Claude Nov 03 '14 at 10:58
  • sorry, my bad, i messed the whole thing, i am really sorry :( – Yazan Nov 03 '14 at 10:58
  • 1
    But as Yazan said the which java returns /usr/java/jdk1.6.0_27/bin/java that is the reason I did that – Claude Nov 03 '14 at 10:59
  • the command rpm -q -f /usr/java/dafault/bin/java returns: jre-1.7.0_40-fcs. What should I do next – Claude Nov 03 '14 at 11:02
  • I don't think that will help, because the command `which` actually returns the particular executable you use when you write `java` on the command line. If it says `/usr/java/jdk1.6.0_27/bin/java` then that's what you're using, not /usr/bin/java (though they may be the same). – RealSkeptic Nov 03 '14 at 11:03
  • So what do you think I should do in this case – Claude Nov 03 '14 at 11:04
  • What about removing the old version, the new version and making a clean install of the jre? – Claude Nov 03 '14 at 11:05
  • @Claude, I added a little bit to my answer about that. But unfortunately, if it was installed manually, chances are you'll have to remove individual files from several system directories, and I'd recommend that only an experienced Red Hat user, preferably a sysadmin, will do that. – RealSkeptic Nov 03 '14 at 11:09
  • In fact I wanted to do it by myself because I though it is just a java install but it seems to be complicated. Do you know any good source of info or a book that can help me do this because it is my first time doing this and I must do it. – Claude Nov 03 '14 at 11:13
  • Just to confirm by someone who knows about RHEL. Is the following correct? – Claude Nov 03 '14 at 11:34
  • Self-extracting file uninstall Find out if Java is installed in some folder. Common locations are /usr/java/jre_ or /opt/jre_nb/jre_/bin/java/ When you have located the folder, you may delete folder. Warning: You should be certain that Java is not already installed using RPM before removing the folder. Type: rm -r jre For example: rm -r jre1.6.0 – Claude Nov 03 '14 at 11:35
0

If you haven't found your answer:

  • leave old java where it is, don't even bother with it
  • install new version with: rpm -ivh /root/jdk-7u40-linux-x64.rpm
  • deactivate old java
  • export new version

Deactivating old java (note entering hashtags before every line, manual installation required editing of profile, so edit it one more):

vi /etc/profile

#JAVA_HOME=/usr/java/jdk1.6.0_27
#export JAVA_HOME
#PATH=$JAVA_HOME/bin:$PATH
#export PATH

Exporting nev version (note adding new lines in profile followed after old entries):

export JAVA_HOME=/usr/java/latest
export JRE_HOME=$JAVA_HOME/jre
export J2RE_HOME=$JAVA_HOME/jre
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$J2RE_HOME/bin:$PATH

Check nev version with standard command for checking of installed sw. Hope this suits your needs. Just wondering: you're trying to prepare BFBOX for acceptance? Just courious! If you want more info please send me an email, ok?