Note that there are some explanatory texts on larger screens.

plurals
  1. PORunning Python scripts in Java
    primarykey
    data
    text
    <p>I'm trying to run a python script during the execution of my java code, because it will depend on the output received from the python script. So far I've tried using jythonc, unfortunately to no success, and now im trying to use the java <a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Runtime.html" rel="nofollow">Runtime</a> and java <a href="http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/Process.html" rel="nofollow">Process</a> to execute the python script.</p> <p>Now I've run into a problem when trying to call the python script. I feel as though it doesn't even call the script because it takes less than a couple seconds to get to the next page.... </p> <p>Could the problem be how I am calling the python script?? I am trying to run this through a web application...</p> <p>Here is some of my code: </p> <pre><code> String run = "cmd /c python duplicatetestingoriginal.py" ; boolean isCreated = fwr.writeFile(BugFile, GD, 500, true, 5, "LET"); if(isCreated){ try{ r = Runtime.getRuntime(); p = r.exec(run); BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream())); BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream())); String line = ""; while ((line = stdInput.readLine()) != null) { System.out.println(line); } while ((line = stdError.readLine()) != null) { errorW.write(line); } int exitVal = p.waitFor(); arrayList = fwr.readResults(); }catch(Exception e){ } } else{ // troubleshoot.... } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload