ANT中无法识别的选项问题

时间:2014-06-23 15:44:02

标签: java windows ant

我尝试使用相当多的资源来尝试理解为什么在尝试从命令行运行ant时出现以下错误:

Unrecognized option: -dant.home=C:\ANT\1.7.0
Could not create the Java virtual machine.

ERROR: The file is either empty or does not contain the valid choices.

为了提供一点见解,我的路径包括%JAVA_HOME%和%ANT_HOME%\ bin。 我不能做的事情之一是以管理员身份运行以更新系统变量,仅更新用户变量。有没有人遇到过这个?谢谢你的帮助!

编辑:为了更新,我在ant.bat顶部取消注释@echo并运行ant.bat以显示下面发生的未识别选项:

C:\ANT\1.7.0\bin>if not "" == "" goto runantwithjikes

C:\ANT\1.7.0\bin>if "no" == "no" goto runantnoclasspath

C:\ANT\1.7.0\bin>"C:\Java\jdk1.6.0_03\bin\java.exe"  -classpath "C:\ANT\1.7.0\li
b\ant-launcher.jar" "-dant.home=C:\ANT\1.7.0" org.apache.tools.ant.launch.launch
er
Unrecognized option: -dant.home=C:\ANT\1.7.0
Could not create the Java virtual machine.

更新: 我认为在做了更多研究之后,它必须与尝试解析launcher.jar文件的classpath变量相关。如果有人在Windows中遇到这个,如果他们知道接下来要做什么就会很棒。另外,我没有使用自定义ant库。

更新: 我决定在这个页面中加入一些调试。希望这没关系,我在第130行之后回显了批处理文件的其余部分:

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Windows\SysWOW64>ant
DEBUG DEBUG DEBUG Attempting to execute an Ant java process
C:\Windows\SysWOW64>if "no" == "no" goto runantnoclasspath

C:\Windows\SysWOW64>"C:\Program Files (x86)\Java\jdk1.7.0_04\bin\java.exe"  -cla
sspath "C:\ANT\1.7.0\lib\ant-launcher.jar" "-dant.home=C:\ANT\1.7.0" org.apache.
tools.ant.launch.launcher
Unrecognized option: -dant.home=C:\ANT\1.7.0
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

C:\Windows\SysWOW64>rem check the error code of the ant build

C:\Windows\SysWOW64>if not "Windows_NT" == "windows_nt" goto onerror

C:\Windows\SysWOW64>rem windows 9x way of checking the error code.  it matches v
ia brute force.

C:\Windows\SysWOW64>for %i in (1 10 100) do set err%i=

C:\Windows\SysWOW64>set err1=

C:\Windows\SysWOW64>set err10=

C:\Windows\SysWOW64>set err100=

C:\Windows\SysWOW64>for %i in (0 1 2) do if errorlevel %i00 set err100=%i

C:\Windows\SysWOW64>if errorlevel 000 set err100=0

C:\Windows\SysWOW64>if errorlevel 100 set err100=1

C:\Windows\SysWOW64>if errorlevel 200 set err100=2

C:\Windows\SysWOW64>if 0 == 2 goto onerror200

C:\Windows\SysWOW64>if 0 == 0 set err100=

C:\Windows\SysWOW64>for %i in (0 1 2 3 4 5 6 7 8 9) do if errorlevel %i0 set err
10=%i

C:\Windows\SysWOW64>if errorlevel 00 set err10=0

C:\Windows\SysWOW64>if errorlevel 10 set err10=1

C:\Windows\SysWOW64>if errorlevel 20 set err10=2

C:\Windows\SysWOW64>if errorlevel 30 set err10=3

C:\Windows\SysWOW64>if errorlevel 40 set err10=4

C:\Windows\SysWOW64>if errorlevel 50 set err10=5

C:\Windows\SysWOW64>if errorlevel 60 set err10=6

C:\Windows\SysWOW64>if errorlevel 70 set err10=7

C:\Windows\SysWOW64>if errorlevel 80 set err10=8

C:\Windows\SysWOW64>if errorlevel 90 set err10=9

C:\Windows\SysWOW64>if "" == "" if 0 == 0 set err10=

C:\Windows\SysWOW64>for %i in (0 1 2 3 4 5 6 7 8 9) do if errorlevel %i set err1
=%i

C:\Windows\SysWOW64>if errorlevel 0 set err1=0

C:\Windows\SysWOW64>if errorlevel 1 set err1=1

C:\Windows\SysWOW64>if errorlevel 2 set err1=2

C:\Windows\SysWOW64>if errorlevel 3 set err1=3

C:\Windows\SysWOW64>if errorlevel 4 set err1=4

C:\Windows\SysWOW64>if errorlevel 5 set err1=5

C:\Windows\SysWOW64>if errorlevel 6 set err1=6

C:\Windows\SysWOW64>if errorlevel 7 set err1=7

C:\Windows\SysWOW64>if errorlevel 8 set err1=8

C:\Windows\SysWOW64>if errorlevel 9 set err1=9

C:\Windows\SysWOW64>goto onerrorend

C:\Windows\SysWOW64>set ant_error=1

C:\Windows\SysWOW64>for %i in (1 10 100) do set err%i=

C:\Windows\SysWOW64>set err1=

C:\Windows\SysWOW64>set err10=

C:\Windows\SysWOW64>set err100=

C:\Windows\SysWOW64>rem bug id 32069: resetting an undefined env variable change
s the errorlevel.

C:\Windows\SysWOW64>if not "C:\Program Files (x86)\Java\jdk1.7.0_04\bin\java.exe
" == "" set _javacmd=

C:\Windows\SysWOW64>if not "" == "" set ant_cmd_line_args=

C:\Windows\SysWOW64>if "1" == "0" goto mainend

C:\Windows\SysWOW64>rem set the return code if we are not in nt.  we can only se
t

C:\Windows\SysWOW64>rem a value of 1, but it's better than nothing.

C:\Windows\SysWOW64>if not "Windows_NT" == "windows_nt" echo 1   1>nul  | choice
 /n /c:1

ERROR: The file is either empty or does not contain the valid choices.

C:\Windows\SysWOW64>rem set the errorlevel if we are running nt.

C:\Windows\SysWOW64>if "Windows_NT" == "windows_nt" color 00

C:\Windows\SysWOW64>goto omega
C:\Windows\SysWOW64>

我特别关注的是这部分:

C:\Windows\SysWOW64>"C:\Program Files (x86)\Java\jdk1.7.0_04\bin\java.exe"  -cla
sspath "C:\ANT\1.7.0\lib\ant-launcher.jar" "-dant.home=C:\ANT\1.7.0" org.apache.
tools.ant.launch.launcher

我在apache手册上看到你不应该改变类路径,所以我把它留下了。

0 个答案:

没有答案