I installed java in opt/jdk1.7.75 having following directories-->

bin
db
include
jre
lib
man
COPYRIGHT
LICENSE
README.html
relase

& other files I set JAVA_HOME path in .bashrc file as follow:

JAVA_HOME=/opt/jdk1.7.75
export JAVA_HOME
PATH=$PATH:$JAVA_HOME
export PATH

On running echo $JAVA_HOME path it is pointing as follow:

/opt/jdk1.7.75

My question is How to verify if the path is correct or incorrect? As most post says run echo command, echo simply gives the path what u have set,it does not tell you if it is correct or incorrect.

Can anybody explain How to VERIFY path is correct or incorrect

Thanks in advance


Solution 1:

Your $JAVAHOME is pointing to the correct location. But the path should have $JAVAHOME/bin directory and not $JAVAHOME itself.

JAVA_HOME="/opt/jdk1.7.75"
export JAVA_HOME
PATH="$PATH:$JAVA_HOME/bin"

You should consider using the Oracle Java PPA instead. It usually does more than what a manual installation would do. You don't have to worry about setting up the environment variables either. That's what most people use.

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer

Try running java -version and javac -version to verify that the path is set.