无法在ant phonegap中运行启动java.exe错误

时间:2012-01-18 14:16:34

标签: java blackberry ant sdk cordova

我在命令提示符下使用了ant的phonegap blackberry。 Windows 7,64x,相当确定Java SDK是32位。 (http://wiki.phonegap.com/w/page/31930982/Getting-Started-with-PhoneGap-BlackBerry-WebWorks

Ant工作正常,java版本返回:

java version "1.7.0"
Java(TM) SE Runtime Environment (build 1.7.0-b147)
Java HotSpot(TM) Client VM (build 21.0-b17, mixed mode)

然而,当我在phonegap示例文件夹中运行ant blackberry build时,我得到:

    build:
 generate-cod-name:
 [echo] Generated name: PhoneGapSample.cod
clean:
 [delete] Deleting directory C:\BBWW\phonegap\sample\build
package-app:
[mkdir] Created dir: C:\BBWW\phonegap\sample\build\widget
 [copy] Copying 9 files to C:\BBWW\phonegap\sample\build\widget
  [zip] Building zip: C:\BBWW\phonegap\sample\build\PhoneGapSample.zip

build:
 [exec] [ERROR]             Failed to run launch java.exe.
BUILD SUCCESSFUL
Total time: 0 seconds

我真的不知道我需要什么样的环境变量,但是我把它设置为像phonegap教程一样:

用户变量JAVA_HOME设置为:

C:\Program Files (x86)\Java\jdk1.7.0;%JAVA_HOME%\bin in system

任何想法我都缺少什么?

ant -d blackberry build错误:

Setting project property: properties.blackberry.bbwp.bin -> C:\BBWW\bbwp.exe
[available] Found: C:\BBWW\bbwp.exe
Setting project property: properties.blackberry.bbwp.exists -> true
Class java.util.Vector loaded from parent loader (parentFirst)
     [exec] Current OS is Windows 7
     [exec] Executing 'C:\BBWW\bbwp.exe' with arguments:
     [exec] 'C:\BBWW\phonegap\sample\build\PhoneGapSample.zip'
     [exec] '/o'
     [exec] 'C:\BBWW\phonegap\sample\build'
     [exec]
     [exec] The ' characters around the executable and arguments are
     [exec] not part of the command.
Execute:Java13CommandLauncher: Executing 'C:\BBWW\bbwp.exe' with arguments:
'C:\BBWW\phonegap\sample\build\PhoneGapSample.zip'
'/o'
'C:\BBWW\phonegap\sample\build'

The ' characters around the executable and arguments are
not part of the command.
   [subant] Exiting C:\BBWW\phonegap\sample\blackberry.xml.

BUILD FAILED
C:\BBWW\phonegap\sample\build.xml:39: The following error occurred while executi
ng this line:
C:\BBWW\phonegap\sample\blackberry.xml:156: The following error occurred while e
xecuting this line:
C:\BBWW\phonegap\sample\blackberry.xml:182: Execute failed: java.io.IOException:
 Cannot run program "C:\BBWW\bbwp.exe": CreateProcess error=193, %1 is not a val
id Win32 application
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
        at java.lang.Runtime.exec(Runtime.java:615)
        at org.apache.tools.ant.taskdefs.Execute$Java13CommandLauncher.exec(Exec
ute.java:862)
        at org.apache.tools.ant.taskdefs.Execute.launch(Execute.java:481)
        at org.apache.tools.ant.taskdefs.Execute.execute(Execute.java:495)
        at org.apache.tools.ant.taskdefs.ExecTask.runExecute(ExecTask.java:631)
        at org.apache.tools.ant.taskdefs.ExecTask.runExec(ExecTask.java:672)
        at org.apache.tools.ant.taskdefs.ExecTask.execute(ExecTask.java:498)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
        at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.jav
a:106)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
        at net.sf.antcontrib.logic.IfTask.execute(IfTask.java:217)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.jav
a:106)
        at org.apache.tools.ant.TaskAdapter.execute(TaskAdapter.java:154)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
        at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.jav
a:106)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
        at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.jav
a:106)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.jav
a:398)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
        at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.jav
a:106)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.Target.execute(Target.java:390)
        at org.apache.tools.ant.Target.performTasks(Target.java:411)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
        at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(Single
CheckExecutor.java:38)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
        at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:442)
        at org.apache.tools.ant.taskdefs.SubAnt.execute(SubAnt.java:302)
        at org.apache.tools.ant.taskdefs.SubAnt.execute(SubAnt.java:221)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.jav
a:106)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.Target.execute(Target.java:390)
        at org.apache.tools.ant.Target.performTasks(Target.java:411)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
        at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExe
cutor.java:41)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
        at org.apache.tools.ant.Main.runBuild(Main.java:809)
        at org.apache.tools.ant.Main.startAnt(Main.java:217)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
Caused by: java.io.IOException: CreateProcess error=193, %1 is not a valid Win32
 application
        at java.lang.ProcessImpl.create(Native Method)
        at java.lang.ProcessImpl.<init>(ProcessImpl.java:188)
        at java.lang.ProcessImpl.start(ProcessImpl.java:132)
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:1021)
        ... 66 more

Total time: 0 seconds

C:\BBWW\phonegap\sample>

来自ant -diagnostics的JAVA INFO:

java.runtime.name : Java(TM) SE Runtime Environment
sun.boot.library.path : C:\Program Files (x86)\Java\jdk1.7.0\jre\bin
java.vm.version : 21.0-b17
ant.library.dir : C:\ANT\lib
user.country.format : GB
java.vm.vendor : Oracle Corporation
java.vendor.url : http://java.oracle.com/
path.separator : ;
java.vm.name : Java HotSpot(TM) Client VM
file.encoding.pkg : sun.io
user.script :
user.country : US
sun.java.launcher : SUN_STANDARD
sun.os.patch.level : Service Pack 1
java.vm.specification.name : Java Virtual Machine Specification
user.dir : C:\BBWW\phonegap\sample
java.runtime.version : 1.7.0-b147
java.awt.graphicsenv : sun.awt.Win32GraphicsEnvironment
java.endorsed.dirs : C:\Program Files (x86)\Java\jdk1.7.0\jre\lib\endorsed
os.arch : x86

java.vm.specification.vendor : Oracle Corporation
user.variant :
os.name : Windows 7
ant.home : C:\ANT
sun.jnu.encoding : Cp1252
java.library.path : C:\Program Files (x86)\Java\jdk1.7.0\bin;C:\Windows\Sun\Java
\bin;C:\Windows\system32;C:\Windows;%CommonProgramFiles%\Microsoft Shared\Window
s Live;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System
32\WindowsPowerShell\v1.0\;C:\ANT\bin;C:\Program Files (x86)\QuickTime\QTSystem\
  ;%JAVA_HOME%\bin;C:\Program Files (x86)\Java\jdk1.7.0\bin;.
java.specification.name : Java Platform API Specification
java.class.version : 51.0
sun.management.compiler : HotSpot Client Compiler
os.version : 6.1
java.awt.printerjob : sun.awt.windows.WPrinterJob
java.specification.version : 1.7
file.encoding : Cp1252
java.class.path : C:\ANT\lib\ant-launcher.jar;C:\Program Files (x86)\Java\jdk1.7
.0\bin\;C:\ANT\lib\ant-antlr.jar;C:\ANT\lib\ant-apache-bcel.jar;C:\ANT\lib\ant-a
pache-bsf.jar;C:\ANT\lib\ant-apache-log4j.jar;C:\ANT\lib\ant-apache-oro.jar;C:\A
NT\lib\ant-apache-regexp.jar;C:\ANT\lib\ant-apache-resolver.jar;C:\ANT\lib\ant-a
pache-xalan2.jar;C:\ANT\lib\ant-commons-logging.jar;C:\ANT\lib\ant-commons-net.j
ar;C:\ANT\lib\ant-jai.jar;C:\ANT\lib\ant-javamail.jar;C:\ANT\lib\ant-jdepend.jar
;C:\ANT\lib\ant-jmf.jar;C:\ANT\lib\ant-jsch.jar;C:\ANT\lib\ant-junit.jar;C:\ANT\
lib\ant-junit4.jar;C:\ANT\lib\ant-launcher.jar;C:\ANT\lib\ant-netrexx.jar;C:\ANT
\lib\ant-swing.jar;C:\ANT\lib\ant-testutil.jar;C:\ANT\lib\ant.jar;C:\Program Fil
es (x86)\Java\jdk1.7.0\lib\tools.jar
java.vm.specification.version : 1.7
sun.arch.data.model : 32
java.home : C:\Program Files (x86)\Java\jdk1.7.0\jre
sun.java.command : org.apache.tools.ant.launch.Launcher -cp C:\Program Files (x8
6)\Java\jdk1.7.0\bin -diagnostics
java.specification.vendor : Oracle Corporation
user.language : en
awt.toolkit : sun.awt.windows.WToolkit
java.vm.info : mixed mode
java.version : 1.7.0
java.ext.dirs : C:\Program Files (x86)\Java\jdk1.7.0\jre\lib\ext;C:\Windows\Sun\
Java\lib\ext
sun.boot.class.path : C:\Program Files (x86)\Java\jdk1.7.0\jre\lib\resources.jar
;C:\Program Files (x86)\Java\jdk1.7.0\jre\lib\rt.jar;C:\Program Files (x86)\Java
\jdk1.7.0\jre\lib\sunrsasign.jar;C:\Program Files (x86)\Java\jdk1.7.0\jre\lib\js
se.jar;C:\Program Files (x86)\Java\jdk1.7.0\jre\lib\jce.jar;C:\Program Files (x8
6)\Java\jdk1.7.0\jre\lib\charsets.jar;C:\Program Files (x86)\Java\jdk1.7.0\jre\c
lasses
java.vendor : Oracle Corporation
file.separator : \
java.vendor.url.bug : http://bugreport.sun.com/bugreport/
sun.cpu.endian : little
sun.io.unicode.encoding : UnicodeLittle
sun.desktop : windows
sun.cpu.isalist : pentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86

3 个答案:

答案 0 :(得分:6)

安装新版本的jdk后我遇到了同样的错误。我发现bbwp在bin / bbwp.properties中保存了它的配置。将bbwp.properties中的java标记值替换为正确的jdk位置。

答案 1 :(得分:1)

看起来BlackBerry WebWorks安装存在问题,Windows抱怨C:\BBWW\bbwp.exe不是正确的exe文件。

尝试手动运行Ant尝试的相同命令:

C:\BBWW\bbwp.exe C:\BBWW\phonegap\sample\build\PhoneGapSample.zip /o C:\BBWW\phonegap\sample\build\PhoneGapSample.zip

并查看是否出现问题。如果是这样,请尝试重新安装BBWW。

答案 2 :(得分:1)

请在bbwp.exe文件中将bbwp.batwebworks.bat更改为blackberry.xml以获取BlackBerry WebWorks 2.1.0.13,如下所示:

condition property="bbwp" value="${properties.blackberry.bbwp.dir}/bbwp" else="${properties.blackberry.bbwp.dir}/bbwp.exe">
<equals arg1="${isMacOSX}" arg2="true" />

更改为:

condition property="bbwp" value="${properties.blackberry.bbwp.dir}/bbwp" else="${properties.blackberry.bbwp.dir}/webworks.bat">
<equals arg1="${isMacOSX}" arg2="true" />