Modeller Via Java
1
0
Entering edit mode
11.3 years ago

Hey.. I am trying to run modeller application using Java.. as in i am trying to program a bridge using java to access modeller written in python.

 import java.io.*;


public class Demo {



    public static void main(String args[]) {



    String s = null;



    try {



   //     String[]callAndArgs= {"python\",\"my_python.py\",\"arg1\",\"arg2"};

        Process p = Runtime.getRuntime().exec("C:/Program Files/Modeller9.10/bin/mod9.10 /c start C:/model2/script.py");



        BufferedReader stdInput = new BufferedReader(new

             InputStreamReader(p.getInputStream()));



        BufferedReader stdError = new BufferedReader(new

             InputStreamReader(p.getErrorStream()));



        // read the output

        while ((s = stdInput.readLine()) != null) {

            System.out.println(s);

        }



        // read any errors

        while ((s = stdError.readLine()) != null) {

            System.out.println(s);

        }



        System.exit(0);

    }

    catch (IOException e) {

        System.out.println("exception occured");

        e.printStackTrace();

        System.exit(-1);
       }
      }
      }

I initially was getting a fatal error saying Modeller9.10 environment variable not set. But after setting the proper path and home path.. it is not giving any error but instead running into an infinite loop and not producing any output. Please help!

python java modeling • 2.3k views
ADD COMMENT
0
Entering edit mode
11.3 years ago

Hi, if your Java program is running indefinitely without errors and no output, could it be your script.py simply stalls? Then Java will be waiting forever.

ADD COMMENT
0
Entering edit mode

Hi again. Actually my script.py functions perfectly when i invoke it using the modeller's cmd directly. It generates all my models fine. when i am trying to do the same using a java program.. it stalls.

ADD REPLY

Login before adding your answer.

Traffic: 2658 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6