Ant 找不到 Javac。无论我做什么,它总是声称 JAVA_HOME 是“C:\Program Files\Java\jre6”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1063832/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Ant can't find Javac. No matter what I do it always claims JAVA_HOME is "C:\Program Files\Java\jre6"
提问by user129345
...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"
构建失败 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”
I've set an environment variable called JAVA_Home to point to: "C:\Program Files\Java\jdk1.6.0_12"
我已经设置了一个名为 JAVA_Home 的环境变量指向:“C:\Program Files\Java\jdk1.6.0_12”
Javac.exe is definitely in C:\Program Files\Java\jdk1.6.0_12\bin
Javac.exe 肯定在C:\Program Files\Java\jdk1.6.0_12\bin
I've got %JAVA_HOME%\Bin in my PATH variable.
我的 PATH 变量中有 %JAVA_HOME%\Bin 。
I've mucked around with the various 'JavaHome' settings under HKLM\SOFTWARE\JavaSoft and I'm now utterly stuck.
我已经解决了 HKLM\SOFTWARE\JavaSoft 下的各种“JavaHome”设置,现在我完全卡住了。
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.
我想要做的就是使用 netbeans 为该项目创建的 build.xml 从命令行构建一个 Java 小程序。
Any ideas anybody?
有人有什么想法吗?
采纳答案by user129345
Well ANT now works.
那么 ANT 现在可以工作了。
What did I do?
我做了什么?
I removed it from c:\program files and 'reinstalled' it into "c:\ant"
我将它从 c:\program 文件中删除并“重新安装”到“c:\ant”中
Seems like it doesn't like non 8.3 filenames or directories.
似乎它不喜欢非 8.3 文件名或目录。
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.
有趣的是,我这样做只是因为我误读了手册中建议 ANT 不应位于 95/98/ME 上的非 8.3 样式位置的部分。我没有发现操作系统参考并试了一下。我正在运行 Vista。
Oh well...
那好吧...
Thanks for your help guys.
谢谢你们的帮助。
回答by Vincent Ramdhanie
You need to check that the variable name is JAVA_HOMEall uppercase. Also, run path from the command line and ensure that the path statement has the correct value for JAVA_HOME.
您需要检查变量名称是否全部为大写JAVA_HOME。此外,从命令行运行 path 并确保 path 语句具有正确的 JAVA_HOME 值。
回答by Dave Webb
What build process are you running? Is one of the build scripts setting JAVA_HOME
?
您正在运行什么构建过程?是构建脚本设置之一JAVA_HOME
吗?
回答by TheCoolestSid
Just include tools.jar on the ant classpath, wherever it is installed.
只需在 ant 类路径中包含 tools.jar,无论它安装在哪里。
回答by r2d2
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.
在 Eclipse 中,将已安装的 JRE 设置设置为 JDK - 在项目中(项目属性 -> Java 构建路径 -> 库),或首选项中的全局默认值(Java-> 已安装的 JRE)。eclispe 设置比系统变量强。
回答by Atanas Rusev
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
好的,伙计们,对于 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