Note that there are some explanatory texts on larger screens.

plurals
  1. PORunning executable from desktop given me: *ERR* IO-21 invalid STATUS specifier for given file
    primarykey
    data
    text
    <p>I have been trying to run </p> <blockquote> <p><strong>C:\Users\Luis\Desktop\RESEARCHGUIPROJECT\ResearchGUI\CHEMKED\CHEMKED_SOLVER.exe</strong></p> </blockquote> <p>using java or having java use the command prompt to run this executable. Now I believe I was to able to get java to the file but when it runs it the executable gives me <strong><em>ERR</em></strong> <em><strong>IO-21 invalid STATUS specifier for given file</em></strong>.</p> <p>I have ran the executable from the DOS window and usually when that code is given it means the input file has been specified incorrectly. To give background on the solver what it does is read from a file named <strong><em>solverfilepath.txt</em></strong> and in that file a file directory is given to where the file is located. This file is the solvers input named <strong><em>SOLTMP.txt</em></strong>.</p> <p>This error only occurs when I run java but doesn't occur when I run it manually from the command window.</p> <p>I don't know if there might be a way when java is running this program to also have it open the command window to see the executable run in the command prompt.</p> <p>Any suggestions?</p> <pre><code> int i = 1; while(finalTime &lt; 1.0000){ try{ // Execute CHEMKED solver // Added 07/06/2013 from StackOverFlow Runtime rt = Runtime.getRuntime(); String[] CHEMKED = {"C:\\Users\\Luis\\Desktop\\RESEARCHGUIPROJECT\\ResearchGUI\\CHEMKED\\CHEMKED_SOLVER.exe"}; Process pr = Runtime.getRuntime().exec(CHEMKED); BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream())); String line=null; while((line=input.readLine()) != null) { System.out.println("*****"); System.out.println(line); } int exitVal; exitVal = pr.waitFor(); System.out.println("Exited with error code "+exitVal); } catch(Exception e) { System.out.println(e.toString()); e.printStackTrace(); } try{ inputFile3 = new Scanner(new FileReader("CHEMKED\\SOLTMP.txt")); }catch(Exception e){ e.printStackTrace(System.out); } try{ copyFile = new Formatter(new File("CHEMKED\\output-ring1_"+ i +".txt")); }catch(Exception ex){ ex.printStackTrace(System.out); } //copy SOLTMP content to temporary file while(inputFile3.hasNextLine()){ fileLine = inputFile3.nextLine(); copyFile.format("%s%n",fileLine); } copyFile.close(); inputFile3.close(); // Added 07/05/2013 initialTime+= 0.10; finalTime+= 0.10; // Added 07.03 updateFile(); i++; } </code></pre> <p>So here is what I have added so far simply similar to what was done on javaWorld. I haven't had the chance to run it yet, but just seeing if I am headed in the right direction.</p> <pre><code>class StreamGobbler extends Thread { InputStream is; String type; OutputStream os; StreamGobbler(InputStream is, String type) { this(is, type, null); } StreamGobbler(InputStream is, String type, OutputStream redirect) { this.is = is; this.type = type; this.os = redirect; } public void run() { try { PrintWriter pw = null; if (os != null) pw = new PrintWriter(os); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr); String line=null; while ( (line = br.readLine()) != null) { if (pw != null) pw.println(line); System.out.println(type + "&gt;" + line); } if (pw != null) pw.flush(); } catch (IOException ioe) { ioe.printStackTrace(); } } } public void chemked(String args[]) { int i = 1; while(finalTime &lt; 1.0000) { if (args.length &lt; 1) { System.out.println("USAGE java GoodWinRedirect &lt;outputfile&gt;"); System.exit(1); } try{ FileOutputStream fos = new FileOutputStream(args[0]); String[] CHEMKED = { "C:\\Users\\Luis\\Desktop\\RESEARCHGUIPROJECT\\ResearchGUI\\CHEMKED\\CHEMKED_SOLVER.exe"}; Process pr = Runtime.getRuntime().exec(CHEMKED); BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream())); // any error message StreamGobbler errorGobbler = new StreamGobbler(pr.getErrorStream(), "ERROR"); // any output StreamGobbler outputGobbler = new StreamGobbler(pr.getInputStream(), "OUTPUT", fos); // start them off errorGobbler.start(); outputGobbler.start(); String line=null; while((line=input.readLine()) != null) { System.out.println("*****"); System.out.println(line); } int exitVal; exitVal = pr.waitFor(); System.out.println("Exited with error code "+exitVal); fos.flush(); fos.close(); } catch(Exception e) { System.out.println(e.toString()); e.printStackTrace(); } try{ inputFile3 = new Scanner(new FileReader("CHEMKED\\SOLTMP.txt")); }catch(Exception e){ e.printStackTrace(System.out); } try{ copyFile = new Formatter(new File("CHEMKED\\output-ring1_"+ i +".txt")); }catch(Exception ex){ ex.printStackTrace(System.out); } //copy SOLTMP content to temporary file while(inputFile3.hasNextLine()){ fileLine = inputFile3.nextLine(); copyFile.format("%s%n",fileLine); } copyFile.close(); inputFile3.close(); // Added 07/05/2013 initialTime+= 0.10; finalTime+= 0.10; // Added 07.03 updateFile(); i++; } } </code></pre> <p>Let me know thank you.</p> <p><strong>SOLUTION:</strong></p> <pre><code> int i = 1; while(finalTime &lt; 1.0000) { try{ FileOutputStream fos = new FileOutputStream("C:\\Users\\Luis\\Desktop\\RESEARCHGUIPROJECT\\ResearchGUI\\CHEMKED\\error" +i+".txt"); String[] CHEMKED = { "C:\\Users\\Luis\\Desktop\\RESEARCHGUIPROJECT\\ResearchGUI\\CHEMKED\\CHEMKED_SOLVER.exe", "SOLTMP.txt"}; //Process pr = Runtime.getRuntime().exec(CHEMKED); ProcessBuilder builder = new ProcessBuilder(CHEMKED); builder.directory(new File("C:\\Users\\Luis\\Desktop\\RESEARCHGUIPROJECT\\ResearchGUI\\CHEMKED")); builder.redirectError(); Process pr = builder.start(); BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream())); // any error message? StreamGobbler errorGobbler = new StreamGobbler(pr.getErrorStream(), "ERROR"); // any output? StreamGobbler outputGobbler = new StreamGobbler(pr.getInputStream(), "OUTPUT", fos); // kick them off errorGobbler.start(); outputGobbler.start(); int exitVal; exitVal = pr.waitFor(); System.out.println("Exited with error code "+exitVal); fos.flush(); fos.close(); } catch(Exception e) { System.out.println(e.toString()); e.printStackTrace(); } try{ inputFile3 = new Scanner(new FileReader("CHEMKED\\SOLTMP.txt")); }catch(Exception e){ e.printStackTrace(System.out); } try{ copyFile = new Formatter(new File("CHEMKED\\output-ring1_"+ i +".txt")); }catch(Exception ex){ ex.printStackTrace(System.out); } //copy SOLTMP content to temporary file while(inputFile3.hasNextLine()){ fileLine = inputFile3.nextLine(); copyFile.format("%s%n",fileLine); } copyFile.close(); inputFile3.close(); // Added 07/05/2013 initialTime+= 0.10; finalTime+= 0.10; // Added 07.03 updateFile(); i++; } } </code></pre>
    singulars
    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