Maven & JDK 1.7 on Mac

When I try to compile a project with Maven, I get the following error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project webserverlog: Compilation failure [ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK? [ERROR] -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project webserverlog: Compilation failure No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK? 

My JAVA_HOME points to the JDK:

 $ echo $JAVA_HOME /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home $ $JAVA_HOME/bin/javac -version javac 1.7.0_25 javac: no source files Usage: javac <options> <source files> 

I'm not sure why Maven appends '/ jre' to the end of JAVA_HOME, but looking at some other posts this doesn't seem to be a problem:

 $ mvn --version Apache Maven 3.0.4 (r1232337; 2012-01-17 18:44:56+1000) Maven home: /Users/jerry/dev/springsource/apache-maven-3.0.4 Java version: 1.7.0_25, vendor: Oracle Corporation Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents/Home/jre Default locale: en_US, platform encoding: UTF-8 OS name: "mac os x", version: "10.8.4", arch: "x86_64", family: "mac" 

I searched for a solution to this problem and tried different things in the last couple of days, but I can not find anything that works. I saw some topics with a similar problem, but none of the suggestions worked for me.

Does anyone know how to solve this? Any help is much appreciated ...

+4
source share
2 answers

You should assign the real JDK path to the JAVA_HOME variable instead of leaving the CurrentJDK literal. For some reason, on Mac OS X, the CurrentJDK does not point to the actual version of Maven. Try something similar in your .profile, but replacing your actual jdk folder name:

 export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home 
+3
source

FYI, one of the reasons for the lack of source files is the lack of disk space wherever tmp indicates.

It seems that maven and javac store some elements in TEMP / TMP / TMDIR, and if this director does not exist, he does not have enough space, he does not have enough permissions, then you can see this problem. at least we did on the windows, and I suspect that this will happen in the best operating systems.

0
source

Source: https://habr.com/ru/post/1487176/


All Articles