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

后端 未结 19 1044
误落风尘
误落风尘 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:13

    I struggled with the same issue, and the following worked for me.

    Step 1: Check your JAVA_HOME setting. It may look something like:

    JAVA_HOME="/usr/libexec/java_home"
    

    Step 2: Update JAVA_HOME like so:

    $ vim .bash_profile 
    
    export JAVA_HOME=$(/usr/libexec/java_home)
    
    $ source .bash_profile
    

    Step 3: In a new shell, check that the Maven command is now working properly:

    $ mvn -version
    

    If this fixed the problem, you should get back a response like:

    Apache Maven 3.0.3 (r1075438; 2011-03-01 01:31:09+0800)
    Maven home: /usr/share/maven
    Java version: 1.7.0_05, vendor: Oracle Corporation
    Java home: /Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home/jre
    Default locale: en_US, platform encoding: UTF-8
    OS name: "mac os x", version: "10.8.2", arch: "x86_64", family: "mac"
    
    0 讨论(0)
  • 2021-02-01 02:14

    Following steps solved the issue for me..

    • Copied the zip file into the Program Files folder and extracted to "apache-maven-3.6.3-bin".

    • Then copied the path, C:\Program Files\apache-maven-3.6.3-bin\apache-maven-3.6.3

    • Then created the new MAVEN_HOME variable within environmental variables with the above path.

    Also added,

    C:\Program Files\apache-maven-3.6.3-bin\apache-maven-3.6.3\bin
    

    address to the "PATH" variable

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

    I was able to solve this problem with these steps:

    1. Uninstall JDK java
    2. Reinstall java, download JDK installer
    3. Add/Update the JAVA_HOME variable to JDK install folder
    0 讨论(0)
  • 2021-02-01 02:17

    The SETX command does not modify the current environment.

    If you run the following batch file:

    setx AAA aaa
    echo AAA=%AAA%
    

    It will print

    AAA=
    

    So your batch file is wrong. You have to use set:

    set AAA=aaa
    

    See What is the difference between SETX and SET in environment variables in Windows.

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

    I had the same problem on Windows 7.

    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
    

    The solution turned out to be very simple - right click on command prompt shortcut and choose "Run as Administrator". After that, the problem disappeared)

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

    In case of windows if there is any space in path to jdk like ("C:\Program Files\jdk") then it doesn't work, but if we keep jdk in a location which doesn't have space then it works fine like ("C:\jdk")

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