Hi there,<div><br><div>In my program, I used this code to launch GetDP:</div><div>First I used an array of command and parameters, but that gave me the same CreateProcess error.</div><div>Now I put every command in a String.format(), and execute it with the following method:</div>
<div><br></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div><span class="Apple-tab-span" style="white-space:pre"> </span>private void executeCommand(String cmd) {</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>try {</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>if(cmd ==null){</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>notifyListeners("Kan het commando niet uitvoeren", ERROR);</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>}</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>Runtime rt = Runtime.getRuntime();</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>if (workDir == null) {</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>notifyListeners("De werkmap is nog niet ingesteld", Infobalie.ERROR);</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>throw new NullPointerException("Werkmap nog niet ingesteld");</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>}</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>System.out.printf("Uitvoeren van commando %s\n", cmd);</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>Process p = rt.exec(cmd, null, workDir);</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>InputStream std = p.getInputStream();</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>InputStreamReader isr = new InputStreamReader(std);</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>BufferedReader br = new BufferedReader(isr);</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>String line = null;</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>while ((line = br.readLine()) != null){</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>notifyListeners(line, (line.startsWith("Warning")?ERROR:NEUTRAAL));</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>}</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>int exitvalue = p.waitFor();</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>notifyListeners(String.format(</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>"Commando uitgevoerd met exitwaarde %d.", exitvalue),</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>Infobalie.SUCCESS);</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>} catch (IOException ioe) {</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>System.out.println(ioe.getMessage());</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>ioe.printStackTrace();</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>} catch (Exception e) {</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>e.printStackTrace();</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>}</div></div><div><br></div><div><br></div></blockquote>This method is called by </div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;">
<div><div><span class="Apple-tab-span" style="white-space:pre"> </span>public void pre(int pre) {</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>String command = null;</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>try {</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>command = String.format("%s %s -msh %s -pre %s",</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>getDpExe.getPath(), problemDefinition.getPath(), geo.getPath(), resolutieLijst.get(pre));</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>} catch (NullPointerException npe) {</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>notifyListeners("Niet genoeg parameters om commando uit te voeren",</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>ERROR);</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>return;</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>}</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>executeCommand(command);</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>}</div></div></blockquote><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;">
<blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div>public void cal() {</div></div></blockquote></blockquote><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;">
<div><div><span class="Apple-tab-span" style="white-space:pre"> </span>String command = null;</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>try {</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>command = String.format("%s %s -msh %s -cal",</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>getDpExe.getPath(), problemDefinition.getPath(), geo.getPath());</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>} catch (NullPointerException npe) {</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>notifyListeners("Niet genoeg parameters om commando uit te voeren",</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>ERROR);</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>return;</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>}</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>executeCommand(command);</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>}</div></div><div><div><span class="Apple-tab-span" style="white-space:pre"> </span>public void pos(int post) {</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>String command = null;</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>try {</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>command = String.format("%s %s -msh %s -pos %s",</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>getDpExe.getPath(), problemDefinition.getPath(), geo.getPath(),</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>postCalculationLijst.get(post));</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>} catch (NullPointerException npe) {</div><div>
<span class="Apple-tab-span" style="white-space:pre"> </span>notifyListeners("Niet genoeg parameters om commando uit te voeren",</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>ERROR);</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>return;</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>}</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>executeCommand(command);</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>}</div></div></blockquote><br><div>Good luck with it!</div><div>Joris</div>