7 Replies Latest reply on Apr 14, 2007 5:39 PM by 807597

    set java path on linux

      hi , i just need a help to show me how to set java path on linux . thanks
        • 1. Re: set java path on linux
          Hi There,

          Do you mean you need to setup your JAVA_HOME or add Java to your PATH?


          PS: Google "setting JAVA_HOME on Linux" and/or "add Java to PATH Linux" should help you out :-)
          • 2. Re: set java path on linux
            To add the bin directory of the jdk to your own PATH, for your own work, try the following inside a bash shell:

            1) Change into your home directory - cd $HOME
            2) Open the file ".bashrc". I recommend vi for simplicity here - vi .bashrc
            3) Add the following line to the file. Replace the term <jdk directory> with the name of your java installation directory - export PATH=/usr/java/<jdk directory>/bin:$PATH
            4) then save and exit vi - :wq
            5) Use the "source" command to force linux to reload the .bashrc file which normally is read only when you log in each time - source .bashrc
            6) You can test your PATH setting by checking for the version - java -version

            Note that if you wish to set the PATH setting for all users of the system, you will want to log in as root in the bash shell and perform the same steps upon the file "/etc/profile" rather than ".bashrc" in the home directory. Careful when editing system files. It's a good idea to make a backup of the file first just in case.

            I did a search on the internet and found this article...
            • 3. Re: set java path on linux
              i tried as u said it didnt work i dont know were i made the mistake can u explain me more. please
              • 4. Re: set java path on linux
                Maybe you are not in bash.
                If you did whatever is written there. type bash to enter the bash shell and then try java or javac.
                Good luck.
                • 5. Re: set java path on linux
                  I have the same question, I am also new to Linux Mandriva 2006

                  Somehow I installed java here ->


                  at /usr directory, I have ->


                  at root,
                  java -version
                  bash: java: command not found

                  jre1.5.0_09 is installed, though.

                  # here is my bash, is this correct?
                  # .bashrc
                  export PATH=/usr/java//home/jose/Download/jre1.5.0_09/bin:$PATH
                  # User specific aliases and functions

                  # Source global definitions
                  if [ -f /etc/bashrc ]; then
                       . /etc/bashrc

                  How can I set the java path?
                  It needs to be set to get jajuk to work.

                  • 6. Re: set java path on linux
                    Hi dude... to set your new java path all you have to do is execute the following line:
                    export JAVA_HOME=/home/jose/Download/jre 1.5.0_09
                    #after the "=" you have to put your new path.... ;)
                    • 7. Re: set java path on linux
                      On some Linux systems they seem to donate a free JAVA_HOME setting to your env variables, so you may need to set both PATH and the JAVA_HOME variable.
                      And the bin directory should be early in the PATH, before /usr/bin.

                      Run 'env' and look for references to JAVA_HOME.

                      I'm not sure which Linux systems would just let you set JAVA_HOME only, but if that worked, that would be your best answer, unless you need to login to many different Linux systems like me.