You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Jerry Stafurik <je...@jerryau.net> on 2013/07/03 13:44:17 UTC

Re: Maven & JDK 1.7 on Mac

I finally got this working.  Just in case someone else has the same problem I've found the solution here: http://stackoverflow.com/questions/17099379/builds-failing-after-upgrading-to-java7-missing-tools-jar-and-bad-class-version.  Basically copying $JAVA_HOME/lib/tools.jar to /Library/Java/Extensions fixed it.

> Hm... I just noticed that is does it for me too, but it works just fine
> when I use it.
> 
> 
>> For some reason Maven adds /jre at the end.  I've seen some posts also
>> with /jre at the end but apparently compiling projects works.  Anyway,
>> here's what my JAVA_HOME looks like:
>> 
>> $ echo $JAVA_HOME
>> /Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
>> 
>> It is set in my .profile:
>> export JAVA_HOME=$(/usr/libexec/java_home)
>> 
>> Where running "$ /usr/libexec/java_home" gives me:
>> /Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
>> 
>> But still when I run "$ mvn --version" I get the path with "/jre":
>> Apache Maven 3.0.4 (r1232337; 2012-01-17 18:44:56+1000)
>> Maven home: /usr/share/maven
>> 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"
>> 
>> 
>> 
>> On 21/06/2013, at 14:19 , "Manfred Moser" <ma...@simpligility.com>
>> wrote:
>> 
>>> You Java home is set up wrongly. Check out the log... it points at the
>>> jre
>>> 
>>> /Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents/Home/jre
>>> 
>>> How have you set up JAVA_HOME?
>>>> Hi,
>>>> 
>>>> 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?
>>>> 
>>>> When I specify the source and target versions as 1.7 in the pom.xml
>>>> Maven
>>>> throws a different error:
>>>> javac: invalid flag: -s.
>>>> 
>>>> Maven info:
>>>> $ 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"
>>>> 
>>>> When I run "$ echo $JAVA_HOME" I get
>>>> /Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home.
>>>> And when I run $ $JAVA_HOME/bin/javac -version I get
>>>> javac 1.7.0_25
>>>> javac: no source files
>>>> Usage: javac <options> <source files>.
>>>> 
>>>> /Library/Java/JavaVirtualMachines/CurrentJDK ->
>>>> /Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk via symlink.
>>>> 
>>>> Compiling project using Maven and the compiler plugin worked fine on
>>>> the
>>>> JDK 1.6 version from Apple.  I'm trying to compile the Java EE 7
>>>> examples
>>>> from Glassfish 4, so need the JDK 7 to work.
>>>> 
>>>> Does anyone else have the same problem?  Any suggestions on how to fix
>>>> this?
>>>> 
>>>> 
>>>> Thanks,
>>>>  Jerry
>>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>> For additional commands, e-mail: users-help@maven.apache.org
>>> 
>>