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.
Modeller Via Java
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!
• 2,837 views
•
link
1 answer
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.
• 0 views
•
link
• 0 views
•
link
Log in to answer this question.