1

I have CentOS 6.7. I installed OpenJDK 1.8 with the following command.

yum install java-1.8.0-openjdk-devel

After installing I executed the following two commands.

export JAVA_HOME=/usr/jdk/jdk1.8.0_121
export PATH=$JAVA_HOME/bin:$PATH

But when I type java -version I still see the following output. I do not see OpenJDK.

java version "1.8.0_121"

Java(TM) SE Runtime Environment (build 1.8.0_121-b13)

Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

EDIT

I have posted a similar thread, regarding not finding 'javac' in the thread -bash: javac: command not found” error after installing OpenJDK 1.7 In that thread I was not able to execute javac which was resolved and it was about OpenJDK 1.7 (not 1.8). But this thread is all about java -version not showing OpenJDK for OpenJDK 1.8.

5
  • 1
    You appeared to have installed the "devel" package, which looks to me like it installs .../bin/java to a subdirectory of /usr/lib/jvm/, not /usr/jdk/
    – Jeff Schaller
    Apr 6, 2017 at 12:33
  • Possible duplicate of "-bash: javac: command not found" error after installing OpenJDK 1.7
    – Jeff Schaller
    Apr 6, 2017 at 12:38
  • One strange thing I have observed it that, after I removed OpenSDK 1.8 by executing yum remove command, I still see the same output for java -version command. If I execute the command yum list installed | grep java* I do not see OpenSDK 1.8 package. So I am now really confused.
    – KurioZ7
    Apr 7, 2017 at 4:07
  • Use type java in bash to find out what you're actually running, and if it's a link follow to its (final) target, then do rpm -qf on that file. Also: Java is OpenJDK, not OpenSDK, which is several somethings completely different. @JeffSchaller: similarly java-1.8.0-openjdk-headless, which is JRE-minus-AWT, installs to /usr/lib/jvm/fullversion/jre, not /usr/jdk. And the CentOS 6 repositories I use (AFAIR default) don't (now?) have any java-ver-oracle/sun versions at all. Apr 7, 2017 at 6:56

1 Answer 1

1

Below are steps to find the java:

find / -name java | grep "/bin/java" ---> This will give all paths where you have executable of java

[root@XXXXX ~]# find / -name java | grep "/bin/java"
/usr/bin/java
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.232.b09-1.el6_10.x86_64/bin/java
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.232.b09-1.el6_10.x86_64/jre/bin/java

Once you find the locations just make the below entry for java home for machine: vi /etc/profile ---> add the below lines to the end

export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.232.b09-1.el6_10.x86_64
export PATH=$JAVA_HOME/bin:$PATH

[root@XXXXX ~]# java -version
openjdk version "1.8.0_232"
OpenJDK Runtime Environment (build 1.8.0_232-b09)
OpenJDK 64-Bit Server VM (build 25.232-b09, mixed mode)

In your example you are giving path for JDK not for OpenJDk as below: export JAVA_HOME=/usr/jdk/jdk1.8.0_121 export PATH=$JAVA_HOME/bin:$PATH

Thats why it is showing java even though you have installed OpenJDK.

Let me know if you have any queries.

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .