Maven Unable to locate the Javac Compiler in:
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.
Solution 1:
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:
Solution 2:
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
Solution 3:
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
- Java Build Path >> Libraries
- JRE System Lybrary >> Edit
- Installed JREs >> click on my jdk >> edit
- Add External Jars >> tools.jar
And then compiled fine
Solution 4:
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
Solution 5:
It was an Eclipse problem. When I tried to build it from the command line using
mvn package
it worked fine.