可以创建运行服务器端程序的Java Web Start应用程序吗?

时间:2015-06-11 09:18:38

标签: java python java-web-start

我有一个Java应用程序在我的计算机上运行像Python这样的程序:

Process p = Runtime.getRuntime().exec("C:/python34/pythonw.exe PWtest.pyw")

我需要在网上部署它。现在可以将它变成Java Web Start应用程序,这样当应用程序需要运行python时,它会访问我用python安装的服务器来生成数据吗?否则,我怎么能这样做?

注意:我不希望任何将python程序或.exe打包到.jar文件中的解决方案,因为我调用了其他程序,如PowerWorld,这个应用程序需要可扩展。

1 个答案:

答案 0 :(得分:0)

您可以传递服务器脚本的URL,例如.asp,并读取结果:

public static String excuteHTTPGet(final String targetURL) throws IOException {
    final URL url = new URL(targetURL);
    final HttpURLConnection connection = (HttpURLConnection) url.openConnection();
    connection.setUseCaches(false);
    connection.setDefaultUseCaches(false);
    // Get Response
    final InputStream is = connection.getInputStream();
    final BufferedReader rd = new BufferedReader(new InputStreamReader(is));
    String line;
    final StringBuffer response = new StringBuffer();
    while ((line = rd.readLine()) != null) {
        response.append(line);
        response.append('\r');
    }
    rd.close();
    return response.toString();
}