Maven Installation OSX Error Unsupported major.minor version 51.0

前端 未结 6 1961
轻奢々
轻奢々 2020-12-04 09:14

I installed maven by following this steps:(a tutorial)

JAVA_HOME=/Library/Java/Home
export M2_HOME=/Users/steven/zimmermann/maven
export M2=$M2_HOME/bin
expo         


        
相关标签:
6条回答
  • 2020-12-04 10:03

    In Eclipse, you don't need to change JAVA_HOME, you just need to change the run configuration for Maven to something above 1.6 (even if your project is on Java 6, Maven shouldn't be). Right-click the project, choose Maven Build or Run As > Run Configurations and set the correct JDK version.

    0 讨论(0)
  • 2020-12-04 10:07

    A dynamic $HOME/.zshrc solution, if you're like me ie. Linux @ work; MBP/A @ home

    if [[ $(uname) == "Darwin" ]]; then export OSX=1; fi
    if [[ $(uname) ==  "Linux" ]]; then export LINUX=1; fi
    
    if [[ -n $OSX ]]; then
            export JAVA_HOME=$(/usr/libexec/java_home)
    else
            export JAVA_HOME=/usr/lib/jvm/default-java
    fi
    
    0 讨论(0)
  • 2020-12-04 10:13

    The problem is because you haven't set JAVA_HOME in Mac properly. In order to do that, you should do set it like this:

    export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home

    In my case my JDK installation is jdk1.8.0_40, make sure you type yours.

    Then you can use maven commands.

    Regards!

    0 讨论(0)
  • 2020-12-04 10:13

    Do this in your .profile -

    export JAVA_HOME=`/usr/libexec/java_home`

    (backticks make sure to execute the command and place its value in JAVA_HOME)

    0 讨论(0)
  • 2020-12-04 10:14

    Please rather try:

    $JAVA_HOME/bin/java -version
    

    Maven uses $JAVA_HOME for classpath resolution of JRE libs. To be sure to use a certain JDK, set it explicitly before compiling, for example:

    export JAVA_HOME=/usr/java/jdk1.7.0_51
    

    Isn't there a version < 1.7 and you're using Maven 3.3.1? In this case the reason is a new prerequisite: https://issues.apache.org/jira/browse/MNG-5780

    0 讨论(0)
  • 2020-12-04 10:18

    I solved it putting a old version of maven (2.x), using brew:

    brew uninstall maven
    brew tap homebrew/versions 
    brew install maven2
    
    0 讨论(0)
提交回复
热议问题