我需要直接从actionscript代码调用java命令行jar文件,我需要读回jar的输出,这可能吗?怎么样?
谢谢..
答案 0 :(得分:0)
我找到了一个基于@inverse answer和其他一些资源的解决方案:
var startupInfo = new NativeProcessStartupInfo();
// Define java process -- insert path to java executable -- in my case:"C:/Program Files/Java/jre1.8.0_45/bin/java.exe"
startupInfo.executable = new File("[path to java executable]");
// Setup arguments:
var args:Vector.<String> = new Vector.<String>;
args.push("-jar");
// Here you push your jar path:
args.push("[path to jar]");
// next add any argument you have
args.push("[argument]");
args.push("[argument]");
startupInfo.arguments = args;
var nativeProcess = new NativeProcess();
nativeProcess.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, onOutputData);
nativeProcess.start(startupInfo);
function onOutputData(event:ProgressEvent):void
{
var stdOut = nativeProcess.standardOutput;
var data:String = stdOut.readUTFBytes(nativeProcess.standardOutput.bytesAvailable);
trace("Got: ", data);
}