Check if JAVA_HOME is already set ,
Open Console
Execute : echo $JAVA_HOME
If output is a path , then your JAVA_HOME is set , make sure the path is correct
If output is empty , then execute following steps
Make sure you have installed Java already
Execute: vi ~/.bashrc OR vi ~/.bash_profile
add line : export JAVA_HOME=/usr/java/jre1.8.0_04
save the file
source ~/.bashrc OR source ~/.bash_profile
Execute : echo $JAVA_HOME
Output should print the path