Execute an external EXE from Flex/AIR or Java Web

2019-07-26 08:40发布

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.

Any suggestions, links?

Thanks,

2条回答
The star\"
2楼-- · 2019-07-26 09:40

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();
            }
        }
}
查看更多
相关推荐>>
3楼-- · 2019-07-26 09:44

You cannot execute an executable on the client from a web application on the server. It would be very bad if you could.

You also cannot execute something from AIR, since it is outside the security sandbox. You can, however, do so from an AIR2EXE application like Shu or airAveer, but this will change your deployment strategy.

If you do not need AIR-specific APIs, you can also use a SWF2EXE application like Screenweaver (open source) or Zinc.

查看更多
登录 后发表回答