0

I am new in learning java programming! I want to make a .jar in a maven project. After running this command mvn clean install, I am getting the following error message:

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile(default-compile) on project wps-demo: Compilation failure

Unable to locate the Javac Compiler in:C:\Program Files\Java\jre7..\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 can I do for clean this error!

Community
  • 1
  • 1
iman.tv
  • 97
  • 4
  • 12

4 Answers4

2

It looks like you have only a JRE (Java Runtime Environment) installed, and not a JDK (Java Development Kit), as this error message says:

Please ensure you are using JDK 1.4 or above and not a JRE(the com.sun.tools.javac.Main class is required)

Download and install the JDK (not JRE) from Oracle's website.

The JRE allows you to run Java programs, but does not include the tools that you need to develop Java software, such as the Java compiler. The JDK does include those tools.

If you already have a JDK installed, then make sure that the JAVA_HOME environment variable refers to the directory where you have the JDK installed, and not to a directory with a JRE.

Jesper
  • 202,709
  • 46
  • 318
  • 350
1

As your error says you have wrong value in JAVA_HOME variable in system settings... should be something like C:\Program Files\Java\jre6

You can find how to set it HERE for example.

Community
  • 1
  • 1
Gatekeeper
  • 1,586
  • 3
  • 21
  • 33
0

You need to set the environment variable that specifies the location of your java development kit so that windows can find the Java libraries

Put java home path in a JAVA_HOME variable that you can create in the advanced tab of MyComputer properties.

The Java home path would look something like this

C:\Program Files\Java\jdk1.5

Hope this helps

Code2Interface
  • 495
  • 2
  • 7
0

You may also want to have a look at the following article from Maven http://maven.apache.org/guides/mini/guide-building-jdk14-on-jdk15.html

It states that from Maven 2.2.0, Java JDK 1.5 is needed to allow Maven to build the Java project. The article also goes on to show how some of these adjustments can be made so that JDK 1.5 or later can be used in the build process.

blackpanther
  • 10,998
  • 11
  • 48
  • 78