简体   繁体   中英

Maven - JAVA_HOME location and Compilation failure executing javac

---skippable part---

Hi all, first time here and hopefully I'm not writing a clone of anything else. I spent days looking for cases like mine and all the things I tried failed to work, or couldn't simply find the correct solution for me.

I'm trying to use Maven on another student's project I'm working on (have to continue what he already did) for a school project, on a pc with Ubuntu 14.04. I'm in my project directory downloaded from github and I need to create a .war file and use that for Tomcat. I was following a guide of that student, and probably I'm a little confused on what to do.

---tl:dr i need help---

So when I launch mvn -version , I get this:

Java version: 1.7.0_101, vendor: Oracle Corporation Java home: /usr/lib/jvm/java-7-openjdk-amd64/jre Default locale: it_IT, platform encoding: UTF-8 OS name: "linux", version: "3.19.0-58-generic", arch: "amd64", family: "unix"

Few days ago I had problems with $JAVA_HOME environment variable and probably solved it managing the /etc/environment file, in fact I don't get any error about this. Now when I do a mvn package I get

[INFO] Scanning for projects... [INFO]
[INFO] ------------------------------------------------------------------------ [INFO] Building GWT Maven Archetype 2.6.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-enforcer-plugin:1.3.1:enforce (enforce-versions) @ webprotege --- [INFO] [INFO] --- gwt-maven-plugin:2.7.0:generateAsync (default) @ webprotege --- [INFO] [INFO] --- build-helper-maven-plugin:1.8:add-source (add-source) @ webprotege --- [INFO] Source directory: /home/wapaolo/Documenti/data/webprotege/webprotege/target/generated-sources/gwt added. [INFO] [INFO] --- maven-resources-plugin:2.3:resources (default-resources) @ webprotege --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 10 resources [INFO] [INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ webprotege --- [INFO] Compiling 1744 source files to /home/wapaolo/Documenti/data/webprotege/webprotege/target/webprotege-2.6.0-SNAPSHOT/WEB-INF/classes [INFO] ------------------------------------------------------------- [ERROR] COMPILATION ERROR : [INFO] ------------------------------------------------------------- [ERROR] Failure executing javac, but could not parse the error: javac: invalid target release: 1.8 Usage: javac use -help for a list of possible options

[INFO] 1 error [INFO] ------------------------------------------------------------- [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 5.241s [INFO] Finished at: Mon May 09 16:54:04 CEST 2016 [INFO] Final Memory: 18M/295M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project webprotege: Compilation failure [ERROR] Failure executing javac, but could not parse the error: [ERROR] javac: invalid target release: 1.8 [ERROR] Usage: javac [ERROR] use -help for a list of possible options [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

So what should I do to proceed now? I've no clue..

Your maven project wants java 1.8 but your compiler is 1.7. Look in the pom.xml file for something like

<configuration>
    <source>1.8</source>
    <target>1.8</target>
</configuration>

and change that to 1.7 OR download the 1.8 jdk.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM