#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2009
    Posts
    2
    Rep Power
    0

    Maven, unable to locate javac compiler


    Hi,

    I am new in this site and also newbee in maven, so if any mistake, pls cosider it.

    Sub: I am trying to run pom.xml file through command line. And even I set the JAVA_HOME as per the project requirement(JDK 1.6), and set this to maven path. For other project this is working fine but when I run, got below error:
    Unable to rectify it, pls help urgently.

    Thanks
    Sarfaraz


    [ERROR]

    Mojo:

    org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile

    FAILED for project:

    com.fusionone:f1core:jar:1.97

    Reason:

    Unable to locate the Javac Compiler in:
    C:\Program Files\Java\jre1.6.0_07\..\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.
  2. #2
  3. Feelin' Groovy
    Devshed Supreme Being (6500+ posts)

    Join Date
    Aug 2001
    Location
    WDSMIA
    Posts
    10,135
    Rep Power
    5053
    And even I set the JAVA_HOME...
    Go to a command prompt, type "echo %JAVA_HOME%", press the enter key, then copy/paste the output in this thread.

    You say you've set JAVA_HOME to a JDK, but the error message says you've set it to a JRE, and I'm inclined to believe the error message.

    ~
    Yawmark
    class Sig{public static void main(String...args){\u0066or(int
    \u0020$:"v\"ʲ\"vΤ\"".to\u0043h\u0061rArray()
    )System./*goto/*$/%\u0126//^\u002A\u002Fout.print((char)(($>>
    +(~'"'&'#'))+('<'>>('\\'/'.')/\u002Array.const(~1)\*\u002F)));}}
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2009
    Posts
    2
    Rep Power
    0

    Reply echo %JAVA_HOME%


    Hi,

    Thanks for early reply.

    When I echoed at command prompt, it has given.

    C:\Program Files\Java\jdk1.6.0_10


    You can see in below message, it is searching in tools.jar, but I think, for compilation it has to go to bin folder. am I right?. And I set bin into 'path' already.
    Unable to locate the Javac Compiler in:
    C:\Program Files\Java\jre1.6.0_07\..\lib\tools.jar
    Thanks,
    Sarfaraz
  6. #4
  7. Feelin' Groovy
    Devshed Supreme Being (6500+ posts)

    Join Date
    Aug 2001
    Location
    WDSMIA
    Posts
    10,135
    Rep Power
    5053
    The bottom line to all this is that Maven is looking in your JRE directory when you want it to look in your JDK directory. That means you've got something set up in your environment that you haven't mentioned yet.

    Please describe how you are starting the Maven build (we'll need to make sure you're starting it with the JDK's runtime, not the JRE). Also, post your maven-compiler-plugin element from the pom.
    Yawmark
    class Sig{public static void main(String...args){\u0066or(int
    \u0020$:"v\"ʲ\"vΤ\"".to\u0043h\u0061rArray()
    )System./*goto/*$/%\u0126//^\u002A\u002Fout.print((char)(($>>
    +(~'"'&'#'))+('<'>>('\\'/'.')/\u002Array.const(~1)\*\u002F)));}}
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2009
    Posts
    1
    Rep Power
    0

    Smile eclipse solution


    I got the same, when running maven in eclipse

    Unable to locate the Javac Compiler in:
    C:\Program Files\Java\jre1.6.0_07\..\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.

    What I discovered is that the JRE set from Eclipse was pointing to the "Program Files\Java\Jre...", the one without jdk.The solution was to change the JRE to the "...SDK\jdk\jre..." the one contained in the JDK installation.

    Everything works fine now
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    1
    Rep Power
    0
    Originally Posted by Petru
    What I discovered is that the JRE set from Eclipse was pointing to the "Program Files\Java\Jre...", the one without jdk.The solution was to change the JRE to the "...SDK\jdk\jre..." the one contained in the JDK installation.

    Everything works fine now
    +1 For correct solution

IMN logo majestic logo threadwatch logo seochat tools logo