LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   :bash java: command not found (https://www.linuxquestions.org/questions/linux-newbie-8/bash-java-command-not-found-822230/)

KuraShoko 07-26-2010 09:27 AM

:bash java: command not found
 
Hi everyone, I've just installed java (jre-6u21-linux-i586.bin) on Red Hat 4.4 AS and issued this command to check the java version: java -version
and got :bash :java: command not found

grail 07-26-2010 09:34 AM

So this tells you that the java executable is not in your current path.

Have a look at your install instructions and see if maybe an environment variable needs to be set (maybe JAVA_HOME)

Also, do a find and make sure that the executable does actually exist somewhere??

alli_yas 07-26-2010 09:56 AM

If you try:

Code:

#which java
It should confirm post #2 in that your JAVA_HOME environment variable does not exist AND that you haven't added the executable directory of your Java installation into your PATH.

Basically you need to add the following to your bash_profile:

Code:

export JAVA_HOME=/path/to/my/java/installation/
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin

Once in your PATH at an OS level you can run java -version.

Having JAVA_HOME setup is also very useful in that your application servers and/or IDE will look for this variable.

KuraShoko 07-26-2010 10:25 AM

Thank you. Will try your suggestions and post feedback

knudfl 07-26-2010 11:03 AM

The CentOS way : Something like this :
1) su
2)
Code:

/usr/sbin/alternatives --install /usr/bin/java java /usr/java/jdk1.6.0_21/bin/java 2
( /usr/sbin/alternatives --install /usr/bin/javac javac /usr/java/jdk1.6.0_21/bin/javac 2  )

3) /usr/sbin/alternatives --config java
(( 4) /usr/sbin/alternatives --config javac ))
..


All times are GMT -5. The time now is 04:11 PM.