javaGirl243
javaGirl243

Reputation: 99

Multiple Java installations leading to 'Command not found' error on Linux 2.6 system

I desperately need some help in installing Java on my server on GoDaddy. At first, I followed instructions mentioned here: https://www.tecmint.com/install-apache-tomcat-in-centos because installing Tomcat is my actual goal. I downloaded 'jdk-8u101-linux-x64.rpm' and did everything as mentioned in the tutorial. At the end of it, when I try to test using the command java -version, I get -bash: java: command not found. It didn't work even after logging out and logging in again.

Then I followed instructions as mentioned here: https://in.godaddy.com/help/how-to-install-java-on-ubuntu-12351 and got the same error at the end.

When I try whereis java, I get /usr/bin/java /usr/local/java /usr/share/java. Is it that there are many Java instances and that's why the command isn't executing?

NOTE: The $PATH(/usr/local/jdk/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/cpanel/composer/bin:/usr/local/java/jre1.8.0_25/bin:/usr/local/bin:/usr/X11R6/bin:/root/bin) does include the bin folder of jre.

Any help would be greatly appreciated. Thanks in advance :)

Upvotes: 0

Views: 649

Answers (2)

javaGirl243
javaGirl243

Reputation: 99

Turns out my Java was installed at a different location completely and that wasn't included in the path. This tutorial(https://www.tecmint.com/install-apache-tomcat-in-centos) explains everything in detail except it missed out the point to add Java to the path.

Added that to the path and it's working perfectly since then. Thanks for your help guys :)

Upvotes: 1

Little Santi
Little Santi

Reputation: 8783

I suggest you debug your problem by step by step (Do not follow any step without having success in all the steps before):

  1. Determine which directory java has been installed to. According with the URL you said, it must be /usr/local/java/jre1.8.0_25. Right?
  2. Set the current directory to that path and look for a file named "java", on which you shall have execution permission. If it is not there, java has not been successfully installed. Try re-installing again.
  3. Execute "java -version" from the command line. It should show "1.8.0". If not, the installation is wrong and you should try re-installing too.
  4. Switch to your HOME path, and try to execute "/bin/java". The result should be the same as in point 3.
  5. Ensure that path is correctly included into the PATH environment variable. Try then "java -version". The result should be the same as in point 3. If not, check the PATH variable.

Upvotes: 0

Related Questions