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.
1 Answer 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.
-
If this works for you @KurioZ7 Can you please accept the answer. For accepting it please follow: meta.stackexchange.com/questions/5234/…Santosh Garole– Santosh Garole2020年04月17日 14:39:56 +00:00Commented Apr 17, 2020 at 14:39
.../bin/java
to a subdirectory of/usr/lib/jvm/
, not/usr/jdk/
type java
in bash to find out what you're actually running, and if it's a link follow to its (final) target, then dorpm -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.