简体   繁体   English

为什么closure-maven-plugin无法选择正确的Java版本?

[英]Why doesn't closure-maven-plugin pick up the correct Java version?

I'm trying to compile Storm Starter with JDK 7. 我正在尝试使用JDK 7编译Storm Starter

$ echo $JAVA_HOME                                                                                                 [master] 
/opt/jdk1.7.0_80

$ mvn -version
Apache Maven 3.0.5
Maven home: /usr/share/maven
Java version: 1.7.0_80, vendor: Oracle Corporation
Java home: /opt/jdk1.7.0_80/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.13.0-65-generic", arch: "amd64", family: "unix"

$ mvn clean install -DskipTests=true
                ...
[INFO] --- clojure-maven-plugin:1.7.1:compile (compile-clojure) @ storm-core ---
Compiling backtype.storm.LocalDRPC to /home/incubator-storm/storm-core/target/classes

Exception in thread "main" java.lang.UnsupportedClassVersionError: backtype/storm/ILocalDRPC : Unsupported major.minor version 51.0, compiling:(backtype/storm/LocalDRPC.clj:17:1)
Caused by: java.lang.UnsupportedClassVersionError: backtype/storm/ILocalDRPC : Unsupported major.minor version 51.0

According to this thread, I'm using the wrong version of Java, and I should be using Java 7. But my Java version is 7. So my hunch is that closure-maven-plugin is not picking up the correct Java version when compiling. 根据线程,我使用了错误的Java版本,应该使用Java7。但是我的Java版本 7。所以我的直觉是,closure-maven-plugin在编译时未选择正确的Java版本。 。 How can get this project to compile? 如何使该项目编译?

You need to ensure that $JAVA_HOME/bin (or at least the 1.7 java executable) are first in your PATH as this it's what's used by the plugin. 您需要确保$JAVA_HOME/bin (或至少1.7 java可执行文件)首先在您的PATH因为这是插件使用的方式。

With JAVA_HOME pointing to JDK 1.7, I was able to duplicate this issue by setting the path to java (JDK 1.6 directory) first in my PATH . 使用JAVA_HOME指向JDK 1.7时,我可以通过在PATH首先将路径设置为java (JDK 1.6目录)来复制此问题。 The clojure-maven-plugin code tries to determine this path and falls back to using just java in the current environment/ PATH : clojure-maven-plugin代码尝试确定此路径,并退回到在当前环境/ PATH仅使用java

 private String getJavaExecutable() throws MojoExecutionException {

    Toolchain tc = toolchainManager.getToolchainFromBuildContext("jdk", //NOI18N
                                                                 session);
    if (tc != null) {
      getLog().info("Toolchain in clojure-maven-plugin: " + tc);
      String foundExecutable = tc.findTool("java");
      if (foundExecutable != null) {
        return foundExecutable;
      } else {
        throw new MojoExecutionException("Unable to find 'java' executable for toolchain: " + tc);
      }
    }

    return "java";
  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么docker-maven-plugin无法拾取正确的jar文件以包含在docker映像中? - Why docker-maven-plugin fails to pick up correct jar file to include in docker image? Maven没有运行JAVA_HOME版本,为什么? - Maven doesn't run with the JAVA_HOME version, why? Maven不会在jenkins(linux)上占用资源 - Maven doesn't pick up resources on jenkins(linux) 数独 java,写了一个程序,但不接受重复的数字 - Sudoku java, wrote a program but doesn't pick up on repeated numbers Java:JPanel没有拿起键盘绑定 - Java: JPanel doesn't pick up keyboard bindings 适用于Android的Gradle:javaexec为什么不选择我的类路径? - Gradle for Android: Why doesn't javaexec pick up my classpath? 为什么组件扫描没有拿起我的@Configuration? - Why doesn't component scan pick up my @Configuration? Maven运行配置不会选择活动配置文件,而Spring运行配置会 - Maven run configuration doesn't pick up active profile while Spring run configuration does 为什么这个Java代码有效?编译器不抱怨关闭 - Why is this Java code working? compiler doesn't complain about closure 如何使用Maven版本插件选择下一个版本号? - How to use the maven versions plugin to pick the next version number?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM