jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • Maven Integration for Eclipse
  • MNGECLIPSE-447

Build failure "Unable to locate the Javac Compiler" when trying to execute maven compile goal from Eclipse IDE for project created with M2Plugin

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Cannot Reproduce
  • Affects Version/s: 0.0.12
  • Fix Version/s: 0.9.3
  • Component/s: Maven Launcher
  • Labels:
    None
  • Environment:
    Eclipse 3.2.2, jre1.5.0_11 (jdk -jre1.5.0-11), Windows XP

Description

I would like to use project created with Maven Integration Plugin to be compiled using 'mvn compile' goal from Eclipse IDE, or from command line. My projects would require to use jdk 1.5 and up. Unfortunetly I can't do it without manually changing pom to use 'plexus-eclipse-compiler' plugin when I am trying to compile project in Eclipse IDE, or 'maven-compiler-plugin' when I would like to do it from command line. Is there any way to do it without changing manually pom before to execute mvn compile goal?
In Eclipse IDE I would always get an error(see build errors shown below) if I would not use 'plexus-eclipse-compiler' for mvn compile goal, and of course 'mvn compile from command line would not work with eclipse compiler. I tried to use -vm that you recomended in FAQ section, it doesn't work I am still getting an error (shown below) if I comented out 'plexus-eclipse-compiler' plugin

To reproduce an issue that I am seeing, I created very simple project and simplified set of dependencies to the minimum compare to the original project dependencies. See attached zip file.

So as you can see fom zip that project pom(simplified one) listed two compiler plugins: 'plexus-eclipse-compiler' and 'maven-compiler-plugin', and I have always manually comented one of the plugin to be able to compile without an error. So when I am using Eclipse IDE to avoid "can't find compiler error'' I would require to use plexus-eclipse-compiler and commented out maven-eclipse-compiler, or if I would like to use command line mvn compile for same project I need to comment out eclipse compiler plugin and us it maven compiler. So I can avoid manual modification of project pom, and got work maven compile either from Eclipse IDE or command line?

ERRORS:

[INFO] Build for project: myPureMaven:myPureMaven:jar:0.0.1-SNAPSHOT failed during execution of mojo: org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile
org.apache.maven.ProjectBuildFailureException: Build for project: myPureMaven:myPureMaven:jar:0.0.1-SNAPSHOT failed during execution of mojo: org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:334)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:151)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:220)
at org.apache.maven.embedder.MavenEmbedder.execute(MavenEmbedder.java:813)
at org.maven.ide.eclipse.embedder.Maven2Executor.main(Maven2Executor.java:85)
Caused by: org.apache.maven.plugin.CompilationFailureException: Compilation failure
Unable to locate the Javac Compiler in:
C:\Program Files\Java\jre1.5.0_11\..\lib\tools.jar
Please ensure you are using JDK 1.4 or above and
not a JRE (the com.sun.tools.javac.Main class is required).
In most cases you can change the location of your Java
installation by setting the JAVA_HOME environment variable.

at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:516)
at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:114)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:578)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:508)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:328)
... 4 more
[INFO] ----------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Sun Dec 02 22:16:27 EST 2007
[INFO] Memory 0M/5M
[INFO] ------------------------------------------------------------------------

  • Options
    • Sort By Name
    • Sort By Date
    • Ascending
    • Descending
    • Download All

Attachments

  1. Hide
    Zip Archive
    MavenProject.zip
    02/Dec/07 9:48 PM
    3 kB
    Irene Levina
    1. File
      myPureMaven/.classpath 0.3 kB
    2. File
      myPureMaven/.project 0.6 kB
    3. XML File
      myPureMaven/pom.xml 2 kB
    4. Java Source File
      myPureMaven/src/.../test/MyTestLogger.java 0.3 kB
    Download Zip
    Show
    Zip Archive
    MavenProject.zip
    02/Dec/07 9:48 PM
    3 kB
    Irene Levina

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Brill Pappin added a comment - 05/Dec/07 9:29 PM

This is actually not a problem with the plugin but with the eclipse launcher. Here is the solution that worked for me (and maybe this should be added to the FAQ some place): FYI - I put in a bug for this issue as well a while ago and was told that it wasn't a problem with the plugin (which was correct but not well explained at the time).

Eclipse uses the default JRE when it launches. It locates it using whatever installation magic they both have, however its the wrong one for the the maven compiler plugin needs. To fix this try editing your eclipse.ini file and including the vm you want to use. Make sure it's before the -vmargs param or the launcher will think its an argument for the VM and not for the launcher. I have included a copy of my actual ini file which works (obviously restart eclipse after editing it):

==== eclipse.ini ====
-vm
C:\java\jdk1.6.0\jre\bin\client\jvm.dll
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
-vmargs
-Xms40m
-Xmx256m
-XX:+UseConcMarkSweepGC
-XX:+CMSPermGenSweepingEnabled
-XX:+CMSClassUnloadingEnabled
-XX:MaxPermSize=256m
=================

In case I've goofed and that doesn't work (a small possibility) I can tell you the only other thing I did befroe it worked was add a JAVA_HOME variable to:
Window -> Preferences -> General -> Workspace -> Linked Resources
I haven't removed it yet to check (too lazy and glad things are working) but I'm fairly sure that was not the fix that did the trick.

Show
Brill Pappin added a comment - 05/Dec/07 9:29 PM This is actually not a problem with the plugin but with the eclipse launcher. Here is the solution that worked for me (and maybe this should be added to the FAQ some place): FYI - I put in a bug for this issue as well a while ago and was told that it wasn't a problem with the plugin (which was correct but not well explained at the time). Eclipse uses the default JRE when it launches. It locates it using whatever installation magic they both have, however its the wrong one for the the maven compiler plugin needs. To fix this try editing your eclipse.ini file and including the vm you want to use. Make sure it's before the -vmargs param or the launcher will think its an argument for the VM and not for the launcher. I have included a copy of my actual ini file which works (obviously restart eclipse after editing it): ==== eclipse.ini ==== -vm C:\java\jdk1.6.0\jre\bin\client\jvm.dll -showsplash org.eclipse.platform --launcher.XXMaxPermSize 256m -vmargs -Xms40m -Xmx256m -XX:+UseConcMarkSweepGC -XX:+CMSPermGenSweepingEnabled -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256m ================= In case I've goofed and that doesn't work (a small possibility) I can tell you the only other thing I did befroe it worked was add a JAVA_HOME variable to: Window -> Preferences -> General -> Workspace -> Linked Resources I haven't removed it yet to check (too lazy and glad things are working) but I'm fairly sure that was not the fix that did the trick.
Hide
Permalink
Igor Fedorenko added a comment - 23/May/08 1:24 PM

maven-compiler-plugin needs full JDK to work. You can find instructions how to configure Eclipse to use specific JDK install here http://docs.codehaus.org/display/M2ECLIPSE/Project+FAQ#ProjectFAQ-UnabletolocatetheJavacCompilerError . Please reopen this issue if you still have the problem when running m2eclipse with JDK.

Show
Igor Fedorenko added a comment - 23/May/08 1:24 PM maven-compiler-plugin needs full JDK to work. You can find instructions how to configure Eclipse to use specific JDK install here http://docs.codehaus.org/display/M2ECLIPSE/Project+FAQ#ProjectFAQ-UnabletolocatetheJavacCompilerError . Please reopen this issue if you still have the problem when running m2eclipse with JDK.
Hide
Permalink
Gaute Lote added a comment - 12/Nov/08 4:58 AM

I'm getting the same error and I'm already using a jdk.

eclipse config details:

      • Date: onsdag 12. november 2008 kl. 11.55.11 DE
      • Platform Details:
      • System properties:
        awt.toolkit=sun.awt.windows.WToolkit
        eclipse.buildId=I20080617-2000
        eclipse.commands=-os
        win32
        -ws
        win32
        -arch
        x86
        -showsplash
        D:\dev\eclipse\3.4\eclipse\\plugins\org.eclipse.platform_3.3.100.v200806172000\splash.bmp
        -launcher
        D:\dev\eclipse\3.4\eclipse\eclipse.exe
        -name
        Eclipse
        --launcher.library
        D:\dev\eclipse\3.4\eclipse\plugins\org.eclipse.equinox.launcher.win32.win32.x86_1.0.100.v20080509-1800\eclipse_1114.dll
        -startup
        D:\dev\eclipse\3.4\eclipse\plugins\org.eclipse.equinox.launcher_1.0.100.v20080509-1800.jar
        -showlocation
        -vm
        c:\Program Files\Java\jdk1.6.0_10\bin\..\jre\bin\client\jvm.dll
Show
Gaute Lote added a comment - 12/Nov/08 4:58 AM I'm getting the same error and I'm already using a jdk. eclipse config details:
      • Date: onsdag 12. november 2008 kl. 11.55.11 DE
      • Platform Details:
      • System properties: awt.toolkit=sun.awt.windows.WToolkit eclipse.buildId=I20080617-2000 eclipse.commands=-os win32 -ws win32 -arch x86 -showsplash D:\dev\eclipse\3.4\eclipse\\plugins\org.eclipse.platform_3.3.100.v200806172000\splash.bmp -launcher D:\dev\eclipse\3.4\eclipse\eclipse.exe -name Eclipse --launcher.library D:\dev\eclipse\3.4\eclipse\plugins\org.eclipse.equinox.launcher.win32.win32.x86_1.0.100.v20080509-1800\eclipse_1114.dll -startup D:\dev\eclipse\3.4\eclipse\plugins\org.eclipse.equinox.launcher_1.0.100.v20080509-1800.jar -showlocation -vm c:\Program Files\Java\jdk1.6.0_10\bin\..\jre\bin\client\jvm.dll

People

  • Assignee:
    Igor Fedorenko
    Reporter:
    Irene Levina
Vote (0)
Watch (2)

Dates

  • Created:
    02/Dec/07 9:48 PM
    Updated:
    12/Nov/08 4:58 AM
    Resolved:
    23/May/08 1:24 PM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.