Find the answer to your Linux question:
Results 1 to 5 of 5
I did a search but couldn't find this topic so I hope it's not a repeat. I am pretty new to linux so bear with me. So I downloaded and ...
  1. #1
    Just Joined!
    Join Date
    Oct 2008
    Posts
    2

    -bash: java: command not found



    I did a search but couldn't find this topic so I hope it's not a repeat.

    I am pretty new to linux so bear with me.

    So I downloaded and installed the JRE (java runtime enviro) and now I am trying to run the commands for java.

    myservername:/# java -version
    -bash: java: command not found

    I am trying to use java to install a .jar for commons fvs. But none of the java commands are working. I tried restarting but that didn't do anything. Do I have to enable the commands after installing.

  2. #2
    Linux User
    Join Date
    Feb 2006
    Posts
    484
    Hi

    I think you have installed debian , and debian contains jav in the repositories.

    But if you want the newest version here is the solution.

    you must add java to the path

    find out where you installed java and add it to the path

    export PATH=$PATH:"/path/to/java/jre/bin"

    the bold part is fix.

    for example here is my case

    i have java installed jdk in /usr/java/jdk1.5.0_05/

    set the path

    export PATH=$PATH:"/usr/java/jdk1.5.0_05/bin"


    if you want make this to run every start of a terminal put the export line into your .bashrc file

  3. #3
    Just Joined!
    Join Date
    Oct 2008
    Posts
    2
    Sorry, like I said I am new to this. I didn't quite understand your post.

    I entered in the export PATH=$PATH:"/path/to/java/jre/bin" like you said, but nothing seems to happen. I still get the command not found.

    My Java install is located here as far as I know. I am logged in as root.

    /usr/local/java#

    -r--r--r-- 1 root root 4431 Jan 15 2005 COPYRIGHT
    -r--r--r-- 1 root root 17694 Jan 15 2005 LICENSE
    -r--r--r-- 1 root root 8986 Jan 15 2005 README
    -r--r--r-- 1 root root 16251 Jan 15 2005 README.html
    -r--r--r-- 1 root root 10129 Jan 15 2005 THIRDPARTYLICENSEREADME.txt
    drwxrwxr-x 2 root root 752 Jan 15 2005 bin
    drwxrwxr-x 6 root root 144 Jan 15 2005 demo
    drwxrwxr-x 3 root root 168 Jan 15 2005 include
    drwxrwxr-x 6 root root 368 Jan 15 2005 jre
    drwxrwxr-x 2 root root 192 Feb 4 2005 lib
    drwxrwxr-x 4 root root 128 Jan 15 2005 man
    -rw-rw-r-- 1 root root 11544825 Jan 15 2005 src.zip

  4. #4
    Linux Engineer jledhead's Avatar
    Join Date
    Oct 2004
    Location
    North Carolina
    Posts
    1,077
    in your .bashrc file put this
    Code:
    PATH=$PATH:/opt/java/bin
    export PATH
    JAVA_HOME=/opt/java
    export JAVA_HOME
    and use real values on your machine. either log out and back in or source that file and try again.

    I think you can also make a symlink /etc/alternatives/java and point it to your java file (/usr/local/java/bin/java, or whatever)

  5. #5
    Linux User
    Join Date
    Feb 2006
    Posts
    484
    Hi

    now you know where your java installation is located.

    the code

    export PATH=$PATH:"/usr/local/java/bin"

    or

    exprt PATH=$PATH:"/usr/local/java/jre/bin"

    i am not exactly sure but i think the first command will work

Posting Permissions

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