[Java] NB: JAVA_HOME should point to a JDK not a JRE error when mvn on windows

1 minute read

my cause

  • M2_HOME ,PATH was set in the environment variables as the user environment variable, and JAVA_HOME was set in the system environment variables.
  • Also, the error of NB: JAVA_HOME should point to a JDK not a JRE was not generated because the path destination is JRE, but it was generally displayed when the JDK could not be recognized.

Solution

  • Set JAVA_HOME by user environment variable. environment_variable.png

Operating environment

  • Winodws 10
  • jdk-13.0.1
  • Maven 3.6.3

Background

  • I usually do Android development on Mac, but I happened to touch Spring Boot on Windows and installed Java, Marven on Windows.
  • I have set M2_HOME in the environment variable and also set Path.
  • Maven can’t run because mvn -v gives the following error
  • ``` 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

  • Although JAVA_HOME was already set on the PC and Path was also set, but…

See :bow:

I am indebted to the following articles for the solution