安装蚂蚁;明显误解了JAVA_HOME

发布于 2024-08-27 09:43:33 字数 437 浏览 12 评论 0原文

我正在 Windows XP 计算机上安装 ant,并按照 Apache 手册站点。它说要设置JAVA_HOME,所以我检查了一下,发现没有名为JAVA_HOME的环境变量,创建了一个,并将其设置为“C:\Program Files\Java\jdk1.6.0_19”,

但是当我尝试运行ant debug时,它告诉我 JAVA_HOME 当前设置为“C:\Program Files\Java\jre6”

我猜测 JAVA_HOME 不是环境变量。但如果不是,我就不知道从哪里开始寻找它。有人知道吗?

编辑:哦,是的-它也困扰着我的tools.jar,但我猜当我修复JAVA_HOME问题时,这也将帮助终端找到tools.jar。或者也许我错了。谢谢

I am installing ant on a Windows XP machine, and am following the instructions at Apache's manual site. It said to set JAVA_HOME, so I checked, saw there was no environment variable named JAVA_HOME, made one, and set it to "C:\Program Files\Java\jdk1.6.0_19"

When I try to run ant debug, however, it tells me that JAVA_HOME is currently set to "C:\Program Files\Java\jre6"

I'm guessing JAVA_HOME isn't an environment variable. But if it isn't one, I'm at a loss as to where to start looking for it. Anybody know?

Edit: Oh yeah - it's bugging me for tools.jar as well, but I'm guessing that when I fix the JAVA_HOME issue, that will help the terminal find tools.jar as well. Or maybe I'm wrong. Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

绮筵 2024-09-03 09:43:33

按照 Newtopian 的建议,您可以通过在终端中运行来快速确认该行为是否是问题。

C:\>set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_19
C:\>ant debug

此外,我不确定您输入到 JAVA_HOME 环境变量中的文本是否字面意思是“C:\Program Files\Java\jdk1.1”。 6.0_19",即带引号,但如果是这样,您应该删除引号,因为它们会抛出 ant.bat。

这是 ant.bat 的相关部分

:checkJava
set _JAVACMD=%JAVACMD%

if "%JAVA_HOME%" == "" goto noJavaHome
if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome
if "%_JAVACMD%" == "" set _JAVACMD=%JAVA_HOME%\bin\java.exe
goto checkJikes

:noJavaHome
if "%_JAVACMD%" == "" set _JAVACMD=java.exe

... omitted ...

"%_JAVACMD%" %ANT_OPTS% -classpath "%ANT_HOME%\lib\ant-launcher.jar" "-Dant.home=%ANT_HOME%" org.apache.tools.ant.launch.Launcher %ANT_ARGS% %ANT_CMD_LINE_ARGS%

如果这没有帮助,您可以发布您的调试任务吗?


使其永久化的两个选项:

  1. 运行此:

    C:\>REG 删除 HKCU\Environment /V JAVA_HOME
    C:\>REG 删除 HKLM\Environment /V JAVA_HOME
    C:\>REG add HKCU\Environment /V JAVA_HOME /d "C:\Program Files\Java\jdk1.6.0_19"

基本上,确保您只设置了一个 JAVA_HOME这是正确的;执行此操作后请务必关闭并重新打开终端)

  1. 如果所有其他方法都失败,则蹩脚的批处理文件解决方案:

    @echo 关闭
    设置 JAVA_HOME=C:\Program Files\Java\jdk1.6.0_19
    ant %*

另存为 ant_wrapper.bat (或其他),您应该能够进行 ant_wrapper 调试

(这两种解决方案均未经测试)

Following on Newtopian's suggestions, you can quickly confirm if that behavior is the problem by running in the terminal

C:\>set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_19
C:\>ant debug

Also, I'm not sure if the text you entered into the JAVA_HOME environment variable is literally "C:\Program Files\Java\jdk1.6.0_19", i.e., with quotes, but if so, you should remove the quote marks as they'll throw off ant.bat.

Here's the relevant bit from ant.bat

:checkJava
set _JAVACMD=%JAVACMD%

if "%JAVA_HOME%" == "" goto noJavaHome
if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome
if "%_JAVACMD%" == "" set _JAVACMD=%JAVA_HOME%\bin\java.exe
goto checkJikes

:noJavaHome
if "%_JAVACMD%" == "" set _JAVACMD=java.exe

... omitted ...

"%_JAVACMD%" %ANT_OPTS% -classpath "%ANT_HOME%\lib\ant-launcher.jar" "-Dant.home=%ANT_HOME%" org.apache.tools.ant.launch.Launcher %ANT_ARGS% %ANT_CMD_LINE_ARGS%

If that doesn't help, could you post your debug task?


Two options to make it permanent:

  1. Run this:

    C:\>REG delete HKCU\Environment /V JAVA_HOME
    C:\>REG delete HKLM\Environment /V JAVA_HOME
    C:\>REG add HKCU\Environment /V JAVA_HOME /d "C:\Program Files\Java\jdk1.6.0_19"

(basically, ensure you only have one JAVA_HOME set and it's correct; be sure to close and reopen the terminal after doing this)

  1. If all else fails, the crappy batch file solution:

    @echo off
    set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_19
    ant %*

save as ant_wrapper.bat (or whatever) and you should be able to do ant_wrapper debug.

(Both of these solutions are untested)

高跟鞋的旋律 2024-09-03 09:43:33

确保检查用户和系统范围的环境变量。我不确定这里一个的优先级是什么,但很可能您只检查了一个并在那里创建了它,并且它被另一个覆盖了。

另外,当您创建环境变量时,请确保打开一个新的命令 shell 以使更改生效。然后尝试“set”,它将列出您刚刚创建的命令提示符环境中看到的所有环境变量。

如果一切正常,但 Ant 仍然看不到正确的文件,则检查启动 ANT 的批处理文件(如果 javahome 也没有在那里设置)。如果是,请确保它使用环境变量并且不会尝试再次设置它。

希望这有帮助

Make sure you check both user and system scope environment Variables. I am not certain what is the precedence of one over the other here but most likely you checked as only one and created it there and it is being overridden by the other.

Also when you create the environment variable make sure you open a new command shell for the changes to take effect. then try 'set' that will list all environment variables seen in the environment for the command prompt you just created.

If all is well there but Ant still does not see the correct one then check the batch files that start ANT if the javahome is not set there too. If it is make sure it uses the environment variable and does not try and set it again.

Hope this helps

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文