Skip to main content
added 388 characters in body
Source Link

The reason it didn't work with export$JAVA_HOME exports ais that $JAVA_HOME isn't the same thing as $JAVA_HOME/bin. Your binaries (java, javac, javaws, etc) are all found in the bin directory inside your $JAVA_HOME, not in the $JAVA_HOME itself.

The working line in your question points towards /usr/java/jre1.8.0_51/bin; the JAVA_HOME variable points towards /usr/java/latest, but you still havewhich is a symlink to set it/usr/java/jre1.8.0_51. Either doThat's clearly not the same place.

If you use

export PATH=$PATHPATH="$PATH:$extra$JAVA_HOME/bin"

or doit will work.

PATH=$PATH:$extra
export $PATH

export exports a variable, but you still have to set it. Either do

export PATH=$PATH:$extra

or do

PATH=$PATH:$extra
export $PATH

The reason it didn't work with $JAVA_HOME is that $JAVA_HOME isn't the same thing as $JAVA_HOME/bin. Your binaries (java, javac, javaws, etc) are all found in the bin directory inside your $JAVA_HOME, not in the $JAVA_HOME itself.

The working line in your question points towards /usr/java/jre1.8.0_51/bin; the JAVA_HOME variable points towards /usr/java/latest, which is a symlink to /usr/java/jre1.8.0_51. That's clearly not the same place.

If you use

export PATH="$PATH:$JAVA_HOME/bin"

it will work.

Source Link

export exports a variable, but you still have to set it. Either do

export PATH=$PATH:$extra

or do

PATH=$PATH:$extra
export $PATH