JAVA_HOME incorrectly set. How to reset it? JAVA_HOME incorrectly set. How to reset it? linux linux

JAVA_HOME incorrectly set. How to reset it?


JAVA_HOME typically should only include the folder that contains the bin folder.

So in your case

export JAVA_HOME=/home/user/jdk1.7.0_02/

export PATH=$PATH:$JAVA_HOME/bin

In addition for finding the location of your java_home you can follow this command

which java

(This will return the path of the current java binary. Over here its /usr/bin/java)

ls -alh /usr/bin/java

( This will return true path to the symbolic link. Over here its /etc/alternatives/java.

ls -alh /etc/alternatives/java

( This will return true path to this symbolic link which is actual JAVA HOME path)


  1. Goto Terminal and open either of the following files using an editor of your choice (vim, nano, etc):

    # nano /etc/profile

    (or)

    # nano /root/.bash_profile

    (Instead of root you can also change your normal username.)

  2. Now run the following commands:

    # export JAVA_HOME="/opt/jdk1.6.0"# export PATH="/opt/jdk1.6.0/bin:$PATH"
  3. Logout and logon the system , now check the java version in your terminal using the following command:

    # java -version

    The output should look similar to this:

    # java -versionjava version “1.6.0″Java(TM) SE Runtime Environment (build 1.6.0-b105)Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing)


No... $JAVA_HOME must point to /home/user/jdk1.7.0_02/

To prevent errors like "/home/user" versus "/home/usr", $PATH should be "$PATH:$JAVA_HOME/bin"

And I recommend using a native package (yum, apt-get, etc).