Question: Modeller Via Java
0
gravatar for potassiumiodide0990
6.6 years ago by
United States
potassiumiodide099080 wrote:

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 • 1.5k views
ADD COMMENTlink modified 6.6 years ago by michiel.noback0 • written 6.6 years ago by potassiumiodide099080
0
gravatar for michiel.noback
6.6 years ago by
michiel.noback0 wrote:

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 COMMENTlink written 6.6 years ago by michiel.noback0

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 REPLYlink written 6.6 years ago by potassiumiodide099080
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1638 users visited in the last hour