3

This is the output even though it correctly points to the JDK

C:\Users\{usr}>mvn -version
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

C:\Users\{usr}>echo %JAVA_HOME%
C:\Program Files\Java\jdk1.8.0_191

I tried the opposite which is pointing the JAVA_HOME to the JRE and that worked for me even though it says to set its path to the JDK and not the JRE

Apache Maven 3.6.1 (d66c9c0b3152b2e69ee9bac180bb8fcc8e6af555; 2019-04-05T03:00:29+08:00)
Maven home: C:\Program Files\Maven\apache-maven-3.6.1\bin\..
Java version: 1.8.0_191, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jre1.8.0_191
Default locale: en_PH, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

Details:

  • apache-maven-3.6.1
  • jdk1.8.0_191
  • jre1.8.0_191
  • %JAVA_HOME% = C:\Program Files\Java\jdk1.8.0_191
  • %MAVEN_HOME% = C:\Program Files\Maven\apache-maven-3.6.1

I don't really understand why it behaves this way even though it explicitly says to use the JDK and NOT the JRE

1 Answers1

0

I had the same problem despite setting the JAVA_HOME, MAVEN_HOME, and JAVACMD environment variables on both windows and the Linux subsystem in Linux. I finally got it working by editing the settings.xml file in the conf folder of the maven directory. I added a profile that looked like this:

<profile>
  <id>myprofile</id>

<activation> <jdk>1.8</jdk> </activation>

<properties> <java.home>/path/to/jdk</java.home> </properties> </profile>

and set the the active profile to that profile

 <activeProfiles>
   <activeProfile>myprofile</activeProfile>
 </activeProfiles>

For some reason the java.home maven variable seemed to be different than the JAVA_HOME environment variable.