由网友(一壶老酒)分享简介:需要执行,无论是从Java的Web应用程序(在Windows服务器上运行的Glassfish的)外部的EXE或从的Flex / AIR的桌面应用程序。Need to execute an external EXE from either a Java web app (running on Glassfish on...
需要执行,无论是从Java的Web应用程序(在Windows服务器上运行的Glassfish的)外部的EXE或从的Flex / AIR的桌面应用程序。
Need to execute an external EXE from either a Java web app (running on Glassfish on Windows Server) or from an Flex/AIR desktop app.
任何建议,链接?
谢谢
推荐答案
好吧。我找到了答案...
Okay .. I found the answer ...
import java.io.*;
public class Main {
public static void main(String args[]) {
try {
Runtime rt = Runtime.getRuntime();
//Process pr = rt.exec("cmd /c dir");
Process pr = rt.exec("c:helloworld.exe");
BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream()));
String line=null;
while((line=input.readLine()) != null) {
System.out.println(line);
}
int exitVal = pr.waitFor();
System.out.println("Exited with error code "+exitVal);
} catch(Exception e) {
System.out.println(e.toString());
e.printStackTrace();
}
}
}
相关推荐
最新文章