When i try to generate a war file, it is showing some error like
[ERROR] Unable to locate the Javac Compiler in:
[ERROR] C:\Program Files\Java\jre7\..\lib\tools.jar
When i do echo %path%
it shows
C:\Windows\System32;D:\name\name1\Softwares\Maven\apache-maven-3.0.4\b
in;C:\Program Files\Notepad++\;%JDK_HOME%
When i do echo %JDK_HOME%
D:\name\name\core java\software\Java\Java_1.6.0_04_win\jdk1.6.0_04\bin
I don't know why maven is refering to jre, when my environmental variable is jdk. I also changes installed JRE to jdk1.6.
Its in Eclipse setup only
It has 4 steps TODO.
Step 1 : Right Click on Eclipse project Properties
Step 2 : Java Build Path -> Libraries
Step 3 : Select JRE System Library -> Click Edit button -> Click Installed JREs... button
Step 4 : Edit JRE as Set JRE Home = JAVA_HOME
ScreentShot:
Go to Window -> Preferences... -> Java -> Installed JREs
Edit JRE Home = JAVA_HOME or JAVA_HOME\jre
For example if you use jdk1.6.0_04 which is installed in C:\Program Files, do the following change:
C:\Program Files\Java\jdk1.6.0_04\jre or C:\Program Files\Java\jdk1.6.0_04 instead of the default one which is at C:\Program Files\Java\jre7
Had the same problem, but in my case, the directory eclipse pointed the JRE was the JDK. So, i searched for that tools.jar and was there.
I did
And then compiled fine
The JDK_HOME variable should always point to the base dir of the jdk, not the bin dir:
D:\name\name\core java\software\Java\Java_1.6.0_04_win\jdk1.6.0_04
That defined, fix your path to be
C:\Windows\System32;D:\name\name1\Softwares\Maven\apache-maven-3.0.4\bin;C:\Program Files\Notepad++\;%JDK_HOME%\bin
It was an Eclipse problem. When I tried to build it from the command line using
mvn package
it worked fine.
It sounds like you have JDK_HOME
defined as a user variable and PATH
defined as a System variable, or vice versa - echo %PATH%
should not contain unresolved variables like ...;%JDK_HOME%
.
Make sure that the %JDK_HOME%\bin
path is on your PATH variable, unresolved, even if you have to put the path in explicitly.
I had the same Error, because of JUNIT version, I had 3 3.8.1 and I have changed to 4.8.1.
so the solution is
you have to go to POM, and make sure that you dependency looks like this
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
For others facing this issue in Eclipse even with path set to JDK correctly, you need to remove the other JREs from Installed JREs.
Go to Window -> Preferences -> Java -> Installed JREs
Select unused JREs individually and Remove
It worked for me.
I tried all of the above suggestions, which did not work for me, but I found how to fix the error in my case.
The following steps made the project compile succesfully:
In project explorer, right-click on project, select “properties” In the tree on the right, go to Java build path. Select the tab “libraries”. Click “Add library”. Select JRE system library. Click next. Select radio button Alternate JRE. Click “installed JRE’s”. Select the JRE with the right version. Click Appy and close. In the next screen, click finish. In the properties window, click Apply and close. In the project explorer, right-click your pom.xml and select run as > maven build In the goal textbox, write “install”. Click Run.
This made the project build succesfully in my case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With