Win7下用administrator帐号执行ant命令调java时,会报异常;而用管理员身份执行就没有问题。
异常如下:
E:\doc1\jBPM5.0\jbpm-installer>ant start.h2 Buildfile: E:\doc1\jBPM5.0\jbpm-installer\build.xml download.h2.check: [echo] Checking h2 download ... download.h2: start.h2: [java] E:\doc1\jBPM5.0\jbpm-installer\build.xml:414: java.io.IOException: C reateProcess: "D:\Program Files\Java\jdk1.5.0_06\jre\bin\java.exe" -classpath E: \doc1\jBPM5.0\jbpm-installer\db\driver\h2.jar org.h2.tools.Server -tcp error=740 [java] at org.apache.tools.ant.taskdefs.Java.spawn(Java.java:812) [java] at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:216) [java] at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:135) [java] at org.apache.tools.ant.taskdefs.Java.execute(Java.java:108) [java] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.ja va:291) [java] at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source) [java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMet hodAccessorImpl.java:25) [java] at java.lang.reflect.Method.invoke(Method.java:585) [java] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchU tils.java:106) [java] at org.apache.tools.ant.Task.perform(Task.java:348) [java] at org.apache.tools.ant.Target.execute(Target.java:390) [java] at org.apache.tools.ant.Target.performTasks(Target.java:411) [java] at org.apache.tools.ant.Project.executeSortedTargets(Project.jav a:1399) [java] at org.apache.tools.ant.Project.executeTarget(Project.java:1368) [java] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(De faultExecutor.java:41) [java] at org.apache.tools.ant.Project.executeTargets(Project.java:1251 ) [java] at org.apache.tools.ant.Main.runBuild(Main.java:809) [java] at org.apache.tools.ant.Main.startAnt(Main.java:217) [java] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280) [java] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109) [java] Caused by: java.io.IOException: CreateProcess: "D:\Program Files\Jav a\jdk1.5.0_06\jre\bin\java.exe" -classpath E:\doc1\jBPM5.0\jbpm-installer\db\dri ver\h2.jar org.h2.tools.Server -tcp error=740 [java] at java.lang.ProcessImpl.create(Native Method) [java] at java.lang.ProcessImpl.<init>(ProcessImpl.java:81) [java] at java.lang.ProcessImpl.start(ProcessImpl.java:30) [java] at java.lang.ProcessBuilder.start(ProcessBuilder.java:451) [java] at java.lang.Runtime.exec(Runtime.java:591) [java] at org.apache.tools.ant.taskdefs.Execute$Java13CommandLauncher.e xec(Execute.java:862) [java] at org.apache.tools.ant.taskdefs.Execute.launch(Execute.java:481 ) [java] at org.apache.tools.ant.taskdefs.Execute.spawn(Execute.java:552) [java] at org.apache.tools.ant.taskdefs.Java.spawn(Java.java:810) [java] ... 19 more [java] Java Result: -1 BUILD SUCCESSFUL Total time: 0 seconds
我原来执行的时候是可以的,好像有一次闲得蛋疼使用管理员身份执行一次后,再执行就不行了。这问题还困扰了我两天半,哎~
另外win7的环境变量OS=Windows_NT,ANT获取的是“Windows NT (unknown)”。如果build.xml中有如下内容:
<exec executable="${eclipse.home}/eclipse.exe" spawn="yes" os="Windows 7,Windows Vista,Windows XP,Windows 2000,Windows 2003">
则需要加入“Windows NT (unknown)”,如下
<exec executable="${eclipse.home}/eclipse.exe" spawn="yes" os="Windows NT (unknown),Windows 7,Windows Vista,Windows XP,Windows 2000,Windows 2003">
这样就可以用了。