Results 1 to 5 of 5
i have just installed jdk 1.6.27 on RHEL 5.1, have also defined the JAVA_Home. However on typing
# java -version
i get the message,
bash: java: command not found
Please ...
- 09-21-2011 #1Just Joined!
- Join Date
- Sep 2011
- Posts
- 3
unable to view if java installed on RHEL 5.1
i have just installed jdk 1.6.27 on RHEL 5.1, have also defined the JAVA_Home. However on typing
# java -version
i get the message,
bash: java: command not found
Please help me. Could it be that my Java home is not defined properly ?
Smita Chandra
- 09-21-2011 #2
Hi and welcome to the forum.
When you installed java, did you add it to your path?
- 09-21-2011 #3Just Joined!
- Join Date
- Sep 2011
- Posts
- 3
hmmm... am new to linux... how do i set that ?
- 09-21-2011 #4Linux Guru
- Join Date
- May 2011
- Posts
- 1,843
First you need to know where you installed Java, which depends on how you installed it. Did you use an RPM, or did you use an installer/shell script? Let use know and we'll help you figure out where it is installed (if you don't know already).
For the sake of the argument, let's say you installed it to /opt/java. Then you could use bash-code like this:
The key is to make sure the binary file, java, which usually resides in the bin/ sub-directory of the java installation dir, gets put into your PATH environmental variable.Code:if [ -d /opt/java/bin ]; then export JAVA_HOME=/opt/java export CLASSPATH=${JAVA_HOME}/lib/ext echo $PATH|grep -q ${JAVA_HOME}/bin && : || export PATH=${JAVA_HOME}/bin:${PATH} fi
You can put the above code into your bash profile (~/.bashrc, ~/.bash_profile, etc.), but I like to put it into the following global profile (which would get read by everyone logging in with a bash shell, not just you):
If you wanted to be thorough, you could use the alternatives package to make your system use symlinks to properly track the Java package (as it is already doing with some other packages - see the /etc/alternatives dir and 'man alternatives').Code:/etc/profile.d/java.sh
- 09-23-2011 #5Just Joined!
- Join Date
- Sep 2011
- Posts
- 3
thanks atreyu, am going to try this with the help of somebody more familiar with the linux terminology and figure it out. if i fail i will come back to you.


Reply With Quote