ant and java 8 - “major version 52 is newer than 51, the highest major version supported by this compiler”

前端 未结 4 2148
隐瞒了意图╮
隐瞒了意图╮ 2020-12-31 05:34

I am trying to upgrade my ant project from java 7 to java 8.
(the project deployed in \"Eclipse Kepler\" with \"Java™ 8 support to Eclipse Kepler SR2\")

For that

相关标签:
4条回答
  • 2020-12-31 05:58

    Make sure to add JAVA_HOME in the Classpath variables: Window->Java->Build Path->Classpath variables point to "path/to/jdk"

    0 讨论(0)
  • 2020-12-31 06:11

    Please check that the tools.jar used by Ant is from JDK8 and not JDK7.

    Window -> Preferences:

    In the left pane, go to Ant -> Runtime. In the Classpath tab, check the Global Entries.

    0 讨论(0)
  • 2020-12-31 06:11

    In Ubuntu, I simply fixed it by configure javah from jdk(either openjdk or oracle jdk works) 7 to 8:

    $ javah -classpath . -d jni/ NativeSorting
    ./NativeSorting.class: major version 52 is newer than 51, the highest major version supported by this compiler.
      It is recommended that the compiler be upgraded.
    $ sudo update-alternatives --config javah
    There are 4 choices for the alternative javah (providing /usr/bin/javah).
    
      Selection    Path                                         Priority   Status
    ------------------------------------------------------------
      0            /usr/lib/jvm/java-8-openjdk-amd64/bin/javah   1081      auto mode
    * 1            /usr/lib/jvm/java-7-openjdk-amd64/bin/javah   1071      manual mode
      2            /usr/lib/jvm/java-8-openjdk-amd64/bin/javah   1081      manual mode
      3            /usr/lib/jvm/jdk1.7.0_80/bin/javah            1000      manual mode
      4            /usr/lib/jvm/jdk1.8.0_131/bin/javah           1000      manual mode
    
    Press <enter> to keep the current choice[*], or type selection number: 2
    update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/javah to provide /usr/bin/javah (javah) in manual mode
    $ javah -classpath . -d jni/ NativeSorting
    $ 
    
    0 讨论(0)
  • 2020-12-31 06:14

    This error usually comes when there is difference in the JDK version.Please check classpath, java -version and JAVA_HOME set in the environment variable.

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