Ant 找不到 Javac。 无论我做什么,它总是声称 JAVA_HOME 是“C:\Program Files\Java\jre6”
...这是错误的。
这是我收到的错误:
构建失败 C:_TraderPlatform\Clients\Open\Open\Java\Applets\PPDataTransporter\nbproject\build-impl.xml:338:执行此行时发生以下错误: C:_TraderPlatform\Clients\Open\Open\Java\Applets\PPDataTransporter\nbproject\build-impl.xml:158: 无法找到 javac 编译器; com.sun.tools.javac.Main 不在类路径上。 也许JAVA_HOME没有指向JDK。 它当前设置为“C:\Program Files\Java\jre6”
我已设置一个名为 JAVA_Home 的环境变量来指向:“C:\Program Files\Java\jdk1.6.0_12”
Javac.exe肯定在 C:\Program Files\Java\jdk1.6.0_12\bin 中,
我的 PATH 变量中有 %JAVA_HOME%\Bin 。
我已经搞乱了 HKLM\SOFTWARE\JavaSoft 下的各种“JavaHome”设置,现在完全陷入困境。
我想做的就是使用 netbeans 为该项目构建的 build.xml 从命令行构建一个 Java 小程序。
有人有什么想法吗?
...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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
现在 ANT 可以工作了。
我做了什么?
我将其从 c:\program files 中删除,并将其“重新安装”到“c:\ant”中
看起来它不喜欢非 8.3 文件名或目录。
有趣的是,我这样做只是因为我误读了手册中建议 ANT 不应位于 95/98/ME 上的非 8.3 风格位置的部分。 我没有发现操作系统参考并尝试了一下。 我运行的是Vista。
哦,好吧...
谢谢你们的帮助。
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.
在 Eclipse 中,将已安装的 JRE 设置设置为 JDK - 在项目中(项目属性 -> Java 构建路径 -> 库),或首选项中的全局默认值(Java -> 安装的 JRE)。 eclispe 设置比系统变量强。
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.
只需将 tools.jar 包含在 ant 类路径中,无论它安装在何处。
Just include tools.jar on the ant classpath, wherever it is installed.
您需要检查变量名称是否为JAVA_HOME全部大写。 另外,从命令行运行 path 并确保路径语句具有正确的 JAVA_HOME 值。
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.
您正在运行什么构建过程? 构建脚本之一是否设置
JAVA_HOME
?What build process are you running? Is one of the build scripts setting
JAVA_HOME
?好的,伙计们,对于 Windows 7,它需要 JAVA_HOME 作为 Windows 环境变量,我还添加了 C:\Program Files\Java\jdk1.7.0_03\ 和 C:\Program Files\Java\jdk1.7.0_03\bin到 PATH,重新启动 Eclipse,现在它可以工作了......不过我还有其他问题:D
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