【发布时间】:2014-01-23 09:59:08
【问题描述】:
我正在尝试从 AIR 应用程序调用 .jar 文件。我们可以通过 NativeProcess 执行此操作。我的代码是下一个
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
creationComplete="init()">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.controls.Alert;
var process:NativeProcess;
private function init():void
{
if (NativeProcess.isSupported)
{
Alert.show("suport native process.");
setupAndLaunch();
}
}
private function setupAndLaunch():void
{
var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
var file:File = File.userDirectory.resolvePath("xyz.jar");
nativeProcessStartupInfo.executable = file;
process = new NativeProcess();
process.start(nativeProcessStartupInfo);
process.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, onOutputData);
process.addEventListener(ProgressEvent.STANDARD_ERROR_DATA, onErrorData);
process.addEventListener(NativeProcessExitEvent.EXIT, onExit);
process.addEventListener(IOErrorEvent.STANDARD_OUTPUT_IO_ERROR, onIOError);
process.addEventListener(IOErrorEvent.STANDARD_ERROR_IO_ERROR, onIOError);
}
public function onOutputData(event:ProgressEvent):void
{
trace("Got: ", process.standardOutput.readUTFBytes(process.standardOutput.bytesAvailable));
}
public function onErrorData(event:ProgressEvent):void
{
trace("ERROR -", process.standardError.readUTFBytes(process.standardError.bytesAvailable));
}
public function onExit(event:NativeProcessExitEvent):void
{
trace("Process exited with ", event.exitCode);
}
public function onIOError(event:IOErrorEvent):void
{
trace(event.toString());
}
]]>
</fx:Script>
</s:WindowedApplication>
在调试时,它会抛出以下错误
Error: Error #3219: The NativeProcess could not be started. '%1 is not a valid Win32 application.
请帮帮我。
【问题讨论】:
标签: java actionscript-3 apache-flex