Ant can't find Javac. No matter what I do it always claims JAVA_HOME is “C:\Program Files\Java\jre6”

青春壹個敷衍的年華 提交于 2019-12-08 19:05:37

问题


...and that's wrong.

Here's the error I get:

BUILD FAILED C:_TraderPlatform\Clients\Open\Open\Java\Applets\PPDataTransporter\nbproject\build-impl.xml:338: The following error occurred while executing this line: C:_TraderPlatform\Clients\Open\Open\Java\Applets\PPDataTransporter\nbproject\build-impl.xml:158: Unable to find a javac compiler; com.sun.tools.javac.Main is not on the classpath. Perhaps JAVA_HOME does not point to the JDK. It is currently set to "C:\Program Files\Java\jre6"

I've set an environment variable called JAVA_Home to point to: "C:\Program Files\Java\jdk1.6.0_12"

Javac.exe is definitely in C:\Program Files\Java\jdk1.6.0_12\bin

I've got %JAVA_HOME%\Bin in my PATH variable.

I've mucked around with the various 'JavaHome' settings under HKLM\SOFTWARE\JavaSoft and I'm now utterly stuck.

All I wanted to do was build a Java applet from the command line using the build.xml that netbeans had knocked up for the project.

Any ideas anybody?


回答1:


Well ANT now works.

What did I do?

I removed it from c:\program files and 'reinstalled' it into "c:\ant"

Seems like it doesn't like non 8.3 filenames or directories.

Funnily enough I did this only because I misread the part of the manual that suggested ANT shouldn't be in non 8.3 style locations on 95/98/ME. I didn't spot the OS reference and gave it a go. I'm running Vista.

Oh well...

Thanks for your help guys.




回答2:


In eclipse set the installed JRE setting to the JDK - in the project (project properties -> Java Build Path-> Libraries), or global default in preferences (Java->Installed JREs). The eclispe setting is stronger than the system variable.




回答3:


Just include tools.jar on the ant classpath, wherever it is installed.




回答4:


You need to check that the variable name is JAVA_HOME all uppercase. Also, run path from the command line and ensure that the path statement has the correct value for JAVA_HOME.




回答5:


What build process are you running? Is one of the build scripts setting JAVA_HOME?




回答6:


OK, guys, for Windows 7 it needs the JAVA_HOME as a Windows Environmental Variable, I've also added C:\Program Files\Java\jdk1.7.0_03\ and C:\Program Files\Java\jdk1.7.0_03\bin to PATH, restarted Eclipse, now it works.... Well I have other problems though :D



来源:https://stackoverflow.com/questions/1063832/ant-cant-find-javac-no-matter-what-i-do-it-always-claims-java-home-is-c-prog

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!