How do I fix maven error The JAVA_HOME environment variable is not defined correctly?

后端 未结 19 1043
误落风尘
误落风尘 2021-02-01 01:33

Issue:

I am getting the Maven error \"The JAVA_HOME environment variable is not defined correctly\" when I run through Inno setup batch execution. Howe

相关标签:
19条回答
  • 2021-02-01 02:05

    A very common mistake people make is that, when they set JAVA_HOME or JRE_HOME, they set the value to C:\Program Files\Java\jdk1.8.0_221\bin or similar.

    Please note JAVA_HOME and JRE_HOME value should not contain \bin

    0 讨论(0)
  • 2021-02-01 02:06

    It seems that Maven doesn't like the JAVA_HOME variable to have more than one value. In my case, the error was due to the presence of the additional path C:\Program Files\Java\jax-rs (the whole path was C:\Program Files\Java\jdk1.8.0_20;C:\Program Files\Java\jax-rs).

    So I deleted the JAVA_HOME variable and re-created it again with the single value C:\Program Files\Java\jdk1.8.0_20.

    0 讨论(0)
  • 2021-02-01 02:11

    Following is the best way to get of the issue , check following on classpath:

    1. Make sure JAVA_HOME system variable must have till jdk e.g C:\Program Files\Java\jdk1.7.0_80 , don't append bin here.

    2. Because MAVEN will look for jre which is under C:\Program Files\Java\jdk1.7.0_80

    3. Set %JAVA_HOME%\bin in classpath .

    Then try Maven version .

    Hope it will help .

    0 讨论(0)
  • 2021-02-01 02:12

    My JDK is installed at C:\Program Files\Java\jdk1.8.0_144\.
    I had set JAVA_HOME= C:\Program Files\Java\jdk1.8.0_144\, and I was getting this 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
    

    When I changed the JAVA_HOME to C:\Program Files\Java\jdk1.8.0_144\jre, the issue got fixed.
    I am not sure how.

    0 讨论(0)
  • 2021-02-01 02:12

    I have removed JAVA_HOME variable and kept only path and classpath variables by pointing them to jdk and jre respectively. It worked for me.

    0 讨论(0)
  • 2021-02-01 02:12
    SET JAVA_HOME=C:\Program Files\Java\jdk1.8.0
    

    worked fine for me.

    Note - Don't put double quotes over the path as mentioned above. Otherwise when you run

    mvn -version
    

    it will give following error

    Files\java\jdk1.8.0_201\jre""=="" was unexpected at this time.

    0 讨论(0)
提交回复
热议问题