从 Flex/AIR 或 Java Web 应用程序执行外部 EXE [英] Execute an external EXE from Flex/AIR or Java Web Application

查看:27
本文介绍了从 Flex/AIR 或 Java Web 应用程序执行外部 EXE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

需要从 Java Web 应用程序(在 Windows Server 上的 Glassfish 上运行)或从 Flex/AIR 桌面应用程序执行外部 EXE.

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();
            }
        }
}

这篇关于从 Flex/AIR 或 Java Web 应用程序执行外部 EXE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆