Possible to create a Java Web Start application that runs server side programs?

284 views Asked by At

I have a Java application that runs programs like Python on my computer like so:

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

I need to deploy this on the web. Now is it possible to make this into a Java Web Start application such that when the app needs to run python, it accesses my server installed with python to generate data? Otherwise, how else can I do this?

NOTE: I don't want any solution that packages the python program or .exe into the .jar file because I have other programs like PowerWorld invoked and this app needs to be scalable.

1

There are 1 answers

0
Saeid Nourian On

You could pass the url of a server script such as .asp and read the result:

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