7 Replies Latest reply: Apr 14, 2007 12:39 PM by 807597 RSS

    set java path on linux

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

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

          Karianna

          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
            807597
            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...
            http://www.linuxgazette.com/node/9706
            • 3. Re: set java path on linux
              807597
              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
                807597
                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
                  807597
                  I have the same question, I am also new to Linux Mandriva 2006

                  Somehow I installed java here ->

                  /home/jose/Download/jre1.5.0_09

                  at /usr directory, I have ->

                  /usr/java/j2sdk1.4.2_08

                  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
                  fi

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

                  Thanks
                  • 6. Re: set java path on linux
                    807597
                    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
                      807597
                      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.

                      -kto