I would like to believe that it is not installed if so why the system
returned java: /usr/bin/java?
whereis doesn't resolve the symlink. So if /usr/bin/java still exist, even though the symlink target is broken, it will still return java: /usr/bin/java. I recommend you use type -a java to get the correct result. Please note that the symlink target OR non-symlink source file, both must be executable (chmod +x to set it), otherwise type -a command will return not found even though file exist (type will still return regardless of executable).
So, I can simplify like below:
whereis: Still return found even symlink broken or non-executable.
type: Return found even non-executable, and return not found if
symlink broken.
type -a: Return not found when symlink is broken or
non-executable.
All of them will return not found if the input file doesn't exist.
So, what I can advise is install the JDK again, which "Oracle JDK" is preferred over than "OpenJDK".
A good article can be found here.
This is what you can do (Assume your system are x64):
sudo rpm -ivh jdk-8u91-linux-x64.rpm
sudo rpm -ivh jdk-8u91-linux-x64-demos.rpm
The version number of 8u91 version above is keep updating, so you should always visits Oracle websites to find out the latest version. Click the JDK DOWNLOAD button will go to this page which shows the latest version number and its correct filename.
You can also download the docs which the real link can be found here page, and unzip it (Assume your JDK has been installed at /usr/java/jdk1.8.0_91/):
sudo unzip jdk-8u91-docs-all.zip -d /usr/java/jdk1.8.0_91/ #optional
Then use this two commands to choose the correct javac and java. I believe you only have one option (This sample shows jdk1.8.0_74 due to mine is not the latest 8u91):
$ sudo alternatives --config javac
There are 2 programs which provide 'javac'.
Selection Command
-----------------------------------------------
*+ 1 /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.65-3.b17.fc21.x86_64/bin/javac
2 /usr/java/jdk1.8.0_74/bin/javac
Enter to keep the current selection[+], or type selection number: 2
$
$ sudo alternatives --config java
There are 2 programs which provide 'java'.
Selection Command
-----------------------------------------------
* 1 /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.65-3.b17.fc21.x86_64/jre/bin/java
+ 2 /usr/java/jdk1.8.0_74/jre/bin/java
Enter to keep the current selection[+], or type selection number: 2
$
rpm -qa | grep jdkto search for other JDKs installed through package manager. Second, it may be missing a configured java alternative. You may need to configure java alternatives to deal withjava,javac,javawsand other related to jdk - wiki.centos.org/HowTos/JavaRuntimeEnvironment