I get the error:
C:\\dev\\ws\\springapp\\build.xml:81: Unable to find a javac compiler; com.sun.tools.javac.Main is not on the classpath. Perhaps JAVA_HOME does not
Just set the JDK path from the below steps:
Go to 'Run' ->External Tools -> External Tools Configuration
-> Select 'JRE' Then from the DropDown list select the available JDK . ex. jdk1.8.0_25
I faced this problem when building my project with Jenkins. First, it could not find ant.bat
, which was fixed by adding the path to ant.bat to the system environment variable path. Then ant could not find the jdk directory. This was fixed by right-clicking on my computer > properties > advanced > environment variables
and creating a new environment variable called JAVA_HOME
and assigning it a value of C:\Program Files\Java\jdk1.7.0_21
. Don't create this environment variable in User Variables. Create it under System Variables only.
In both cases, I had to restart the system.
I have met the similiar issue. I would link to run Ant task fron Maven build and I got the issue. I have fixed it as bellow steps:
And it worked for me.
If you have JAVA_HOME
set but there's a typo in it, you will also see the bogus reference to a jre6 path.
Quick work around for the same is
Copy C:\Program Files\Java\jdk1.6.0_14\lib\tools.jar to C:\Program Files\Java\jre6\lib\
This exception is coming because JAVA_HOME is being set as C:\Program Files\Java\jre6 and Ant is not able to find tools.jar in it.
The semicolon was throwing me off: I had JAVA_HOME
set to "C:\jdk1.6.0_26;" instead of "C:\jdk1.6.0_26". I removed the trailing semicolon after following Jon Skeet's suggestion to examine the ant.bat
file. This is part of that file:
if "%JAVA_HOME%" == "" goto noJavaHome
if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome
So the semi-colon wasn't being trimmed off the end, causing this to fail to find the file, therefore defaulting to "C:\Java\jre6" or something like that.
The confusing part is that the HowtoBuild page states to use the semi-colon, but that seems to break it.