When I check on maven's version on a virtual environment, I get the following errors:
The JAVA_HOME environment variable is not defined correctly
This environment variable is needed to run this program
NB: JAVA_HOME should point to a JDK not a JRE
However, I am able to print maven's version outside of virtual environment
mvn -version
Apache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d; 2017-10-18T00:58:13-07:00)
Maven home: /usr/local/Cellar/maven/3.5.2/libexec
Java version: 1.8.0_152, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_152.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.11.6", arch: "x86_64", family: "mac"
I have used set in ~/.bash_profile
set JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_152.jdk
set PATH=$JAVA_HOME/jre/bin:$PATH
I don't understand the error as JAVA_HOME is pointing to a JDK and not a JRE? Thanks for answering!