Generator-jhipster: Compiling with Java 8 on MacOS X fails

Created on 11 Apr 2014  路  5Comments  路  Source: jhipster/generator-jhipster

I have:

java -version
java version "1.8.0"
Java(TM) SE Runtime Environment (build 1.8.0-b129)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b69, mixed mode)

If I choose to use Java 8 and start with 'yo hipster'.

mvn spring-boot:run

gives me

INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building agenda 0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> spring-boot-maven-plugin:1.0.1.RELEASE:run (default-cli) @ agenda >>>
[INFO]
[INFO] --- maven-enforcer-plugin:1.3.1:enforce (enforce-versions) @ agenda ---
[WARNING] Rule 1: org.apache.maven.plugins.enforcer.RequireJavaVersion failed with message:
You are running an older version of Java. JHipster requires at least JDK 1.8
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------

The generated pom.xml says:

</requireMavenVersion>
<requireJavaVersion>
  <message>You are running an older version of Java. JHipster requires at least JDK 1.8</message>
   <version>[1.8.0,)</version>
 </requireJavaVersion>

I get the same If I choose Java 7 in the setup (err, not Java 8). It complains about not having Java 7 or greater with the version range [1.7.0,).

Is this a maven enforcer plugin issue?

Even if I then just remove the enforceJavaVersion section I get (with everything set to Java 8):

...
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ agenda ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 71 source files to /Users/oliver/Sources/jhipsterdemo/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.041s
[INFO] Finished at: Fri Apr 11 21:00:58 CEST 2014
[INFO] Final Memory: 12M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project agenda: Fatal error compiling: invalid target release: 1.8 -> [Help 1]
...

Most helpful comment

you need to edit your $HOME/.mavenrc file and setup your JAVA_HOME to:
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home

All 5 comments

did you check if your mvn process uses JDK 1.8?

No I guess it did not, explicit setting JAVA_HOME to /Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home helped.

On Mac OSX you can use jenv (https://github.com/gcuisinier/jenv) to select the java version you want to use in a shell, a folder etc... Also, it manages plugins and it has a maven plugin to link the selected java version to maven.

you need to edit your $HOME/.mavenrc file and setup your JAVA_HOME to:
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home

@irepan It works for me. Thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

trajakovic picture trajakovic  路  4Comments

kaidohallik picture kaidohallik  路  3Comments

RizziCR picture RizziCR  路  3Comments

DanielFran picture DanielFran  路  3Comments

lsadehaan picture lsadehaan  路  3Comments