views:

225

answers:

3
# which java
/usr/bin/which: no java in (/usr/local/jdk/jdk1.5.0_10/bin/java:/usr/local/jdk/jdk1.5.0_10/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin)

I installed java in /usr/local/jdk/jdk1.5.0_10 but cannot run java -version

I get this

$ java -version
-bash: /usr/bin/java: No such file or directory

this is red hat linux

A: 

Can you do ls /usr/local/jdk/jdk1.5.0_10/bin And why is /usr/local/jdk/jdk1.5.0_10/bin/java in your path?

DaDaDom
# ls /usr/javals: /usr/java: No such file or directory
# ls /usr/local/jdk/jdk1.5.0_10/binls: /usr/local/jdk/jdk1.5.0_10/bin: No such file or directory
And why is /usr/local/jdk/jdk1.5.0_10/bin/java in your path?I added it just to see if it works. Shall I remove it?
Java isn't installed where you think it is (/usr/local/jdk...). Try looking in /usr/java/jdk1.5.0_10 instead.
John Stauffer
A: 

Is JAVA_HOME set?

John Stauffer
this are the relevant variables from envJAVA_HOME=/usr/local/jdk/jdk1.5.0_10/bin/javaecho $PATH/usr/local/jdk/jdk1.5.0_10/bin/java:/usr/local/jdk/jdk1.5.0_10/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin:
@John Stauffer - JAVA_HOME is not required (nor supported) by Java or the JDK - it is purely a convention used by _some_ Java applications/libraries to locate the JDK/JRE.
McDowell
+1  A: 

It's not in your path.

use

export PATH=$PATH:/usr/local/jdk/jdk1.5.0_10/bin

export JAVA_HOME=/usr/local/jdk/jdk1.5.0_10

Look at ~/.bash_profile for where to define this permanatly.

Bill
[root@server1 bin]# export PATH=$PATH:/usr/local/jdk/jdk1.5.0_10/bin[root@server1 bin]# export JAVA_HOME=/usr/local/jdk/jdk1.5.0_10[root@server1 bin]# java-bash: java: command not found[root@server1 bin]# java -version-bash: java: command not found
@ttommy851 You have problems with your $PATH setting. Within your jdk there is a bin directory. Within that directory is the "java" executible. That is the "java" that you are not finding. Navigate to that directory and type "ls", you should see the java file. Type "./java", you should see some output of some kind. If you type "echo $PATH" you'll see what your path is set to, you probably need to adjust that.
Bill