Error: JAVA_HOME is not defined correctly executing maven

前端 未结 14 1462
时光说笑
时光说笑 2020-11-28 05:50

I installed java and set path to environment and when I execute echo $JAVA_HOME I get the following output:

/usr/lib/jvm/java-7-oracle/jre/bin/j         


        
相关标签:
14条回答
  • 2020-11-28 06:52

    $JAVA_HOME should be the directory where java was installed, not one of its parts:

    export JAVA_HOME=/usr/lib/jvm/java-7-oracle
    
    0 讨论(0)
  • 2020-11-28 06:52

    I had this same issue but with open jdk and none of the answers here helped. The trouble was that the mvn script was appending /bin/java at the end of JAVA home while trying to run java commands.

    The solution for me was to manually edit the /usr/local/apache-maven/apache-maven-3.3.9/bin/mvn script (your own script might be installed differently; just run which mvn) and change

       if [ -z "$JAVACMD" ] ; then
      if [ -n "$JAVA_HOME"  ] ; then
        if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
          # IBM's JDK on AIX uses strange locations for the executables
          JAVACMD="$JAVA_HOME/jre/sh/java"
        else
          JAVACMD="$JAVA_HOME/bin/java" 
        fi
      else
        JAVACMD="`which java`"
      fi
     fi
    

    To

    if [ -n "$JAVA_HOME"  ] ; then
        if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
          # IBM's JDK on AIX uses strange locations for the executables
          JAVACMD="$JAVA_HOME/jre/sh/java"
        else 
          JAVACMD="$JAVA_HOME"
        fi
      else
        JAVACMD="`which java`"
      fi
    fi
    
    0 讨论(0)
提交回复
热议问题