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.
It sounds like you have
JDK_HOME
defined as a user variable andPATH
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 am able to resolved by doing following steps :
Lastly do Maven Clean and Maven Install.
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:
It was an Eclipse problem. When I tried to build it from the command line using
it worked fine.
Though there are a few non-Eclipse answers above for this question that does not mention Eclipse, they require path variable changes. An alternative is to use the command line option, java.home, e.g.:
Notice the \jre at the end - a surprising necessity.
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.