Find the answer to your Linux question:
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 ...
  1. #1
    Just 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

  2. #2
    Blackfooted Penguin daark.child's Avatar
    Join Date
    Apr 2006
    Location
    West Yorks
    Posts
    4,344
    Hi and welcome to the forum.

    When you installed java, did you add it to your path?

  3. #3
    Just Joined!
    Join Date
    Sep 2011
    Posts
    3
    hmmm... am new to linux... how do i set that ?

  4. #4
    Linux 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:
    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
    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.

    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):
    Code:
    /etc/profile.d/java.sh
    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').

  5. #5
    Just 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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...