【问题标题】:apache ant installation on windows 7在 Windows 7 上安装 apache ant
【发布时间】:2012-09-24 04:39:21
【问题描述】:

我是 ANT 新手,我很难找出问题所在。

我正确设置了所有变量,如下:

ANT_HOME="C:\Users\Spirithief\Documents\apache-ant-1.8.4"
JAVA_HOME="C:\Program Files\Java\jdk1.7.0_07"
PATH=%ANT_HOME%\bin;%JAVA_HOME%\bin

我运行 cmd 命令行得到命令不存在。

我进入了 \bin 文件中的 ant.bat,我将 echo off 设置为 echo on。

这里是 apache 的 svn 中的 batch file

错误出现在这一行:

:stripAntHome
if not _%ANT_HOME:~-1%==_\ goto checkClasspath

它说了,它是不可识别的。

注意:echo %ANT_HOME% 效果很好,其他的也很好,所以这不是问题。

有什么提示吗??

注意:这是批处理文件的执行(我的系统是法语:p):

Microsoft Windows [version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. Tous droits réservés.

C:\Users\Spirithief>ant

C:\Users\Spirithief>REM  Licensed to the Apache Software Foundation (ASF) under
one or more

C:\Users\Spirithief>REM  contributor license agreements.  See the NOTICE file di
stributed with

C:\Users\Spirithief>REM  this work for additional information regarding copyrigh
t ownership.

C:\Users\Spirithief>REM  The ASF licenses this file to You under the Apache Lice
nse, Version 2.0

C:\Users\Spirithief>REM  (the "License"); you may not use this file except in co
mpliance with

C:\Users\Spirithief>REM  the License.  You may obtain a copy of the License at

C:\Users\Spirithief>REM

C:\Users\Spirithief>REM      http://www.apache.org/licenses/LICENSE-2.0

C:\Users\Spirithief>REM

C:\Users\Spirithief>REM  Unless required by applicable law or agreed to in writi
ng, software

C:\Users\Spirithief>REM  distributed under the License is distributed on an "AS
IS" BASIS,

C:\Users\Spirithief>REM  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either ex
press or implied.

C:\Users\Spirithief>REM  See the License for the specific language governing per
missions and

C:\Users\Spirithief>REM  limitations under the License.

C:\Users\Spirithief>REM This is an inordinately troublesome piece of code, parti
cularly because it

C:\Users\Spirithief>REM tries to work on both Win9x and WinNT-based systems. If
we could abandon '9x

C:\Users\Spirithief>REM support, things would be much easier, but sadly, it is n
ot yet time.

C:\Users\Spirithief>REM Be cautious about editing this, and only add WinNT speci
fic stuff in code that

C:\Users\Spirithief>REM only runs on WinNT.

C:\Users\Spirithief>if "" == "" goto homeDrivePathPre

C:\Users\Spirithief>if "C:\Users\Spirithief" == "" goto userProfilePre

C:\Users\Spirithief>if "C:\Users\Spirithief" == "" goto userProfilePre

C:\Users\Spirithief>if exist "C:\Users\Spirithief\antrc_pre.bat" call "C:\Users\
Spirithief\antrc_pre.bat"

C:\Users\Spirithief>if "C:\Users\Spirithief" == "" goto alpha

C:\Users\Spirithief>if "C:\Users\Spirithief" == "" goto alpha

C:\Users\Spirithief>if "C:\Users\Spirithief" == "C:\Users\Spirithief" goto alpha


C:\Users\Spirithief>if "Windows_NT" == "Windows_NT"

C:\Users\Spirithief>if "Windows_NT" == "WINNT"

C:\Users\Spirithief>if ""C:\Users\Spirithief\Documents\apache-ant-1.8.4"" == ""
goto setDefaultAntHome
La syntaxe de la commande n'est pas correcte.
C:\Users\Spirithief>if not _"==_\ goto checkClasspath
C:\Users\Spirithief>

【问题讨论】:

  • 命令行O_O的语法
  • 您是如何设置环境变量的?使用我的电脑 -> 属性 -> 高级 -> 环境变量?
  • 并且您的值中不应包含引号,即ANT_HOME=C:\Users\Spirithief\Documents\apache-ant-1.8.4
  • 你是对的。与 JAVA_HOME 相同。这很奇怪,我想,最好引用...
  • 所以你没有引号还是不行?

标签: java ant installation


【解决方案1】:

删除环境变量中的引号,因为它不是必需的,并且 ant 脚本已经为您添加了它们。

【讨论】:

    【解决方案2】:

    不是你问的答案,但这可能是相关的,应该对你有所帮助:

    http://wiki.apache.org/ant/AntOnWindows

    我可以亲自担保:http://code.google.com/p/winant/

    我从 wiki 获得了链接,所以我会相信它,而且它也可以一次性运行。 :)

    【讨论】:

      【解决方案3】:

      仅供参考,它适用于二进制分发(不是 source-distr。),因为二进制默认包含 \bin 目录。

      【讨论】:

        猜你喜欢
        • 2016-03-03
        • 1970-01-01
        • 2011-03-29
        • 2016-03-31
        • 2014-04-19
        • 1970-01-01
        • 2011-05-13
        • 1970-01-01
        • 2019-06-19
        相关资源
        最近更新 更多