Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
615 views
in Technique[技术] by (71.8m points)

java - Maven build failed: "Unable to locate the Javac Compiler in: jre or jdk issue"

I have my JAVA_HOME set to:

C:Program Files (x86)Javajdk1.6.0_18

After I run maven install, I get this message from Eclipse:

Reason:

Unable to locate the Javac Compiler in:
  C:Program Files (x86)Javajre6..libools.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.

I'm certain that this is the tricky part

Please ensure you are using JDK 1.4 or above and not a JRE

When I run configuration it's set to JRE6. How do I change it to JDK 1.6 which I have already installed?

I even tried to modify the plugin:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.0.2</version>
    <configuration>
        <source>1.6</source>
        <target>1.6</target>
        <executable>C:Program Files (x86)Javajdk1.6.0_18in</executable>
    </configuration>
</plugin>

Still I get the same error.

I use the Eclipse Maven plugin. How can I change from JRE to JDK in Eclipse?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You could try updating the JDK Eclipse is using, as follows:

Add and set the JRE in menu WindowPreferences...JavaInstalled JREs:

JRE type: Standard VM JRE
Name: jdk1.6.0_18
JRE home directory: C:Program Files (x86)Javajdk1.6.0_18

If this is not the case, it's possible that the brackets and spaces in the JAVA_HOME path are causing issues. Try copying your JDK to a different location and updating your JAVA_HOME.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...