// Build executable statement String commandLine = appName + " -r " + appRegNum + appOptions + " -o" + outputFileName + " " + inputFileName; try { // Check if running on Windows if ( System.getProperty ( "os.name", " " ).toUpperCase().startsWith( "WIN" ) ) { commandLine = "cmd /c " + commandLine; } Process cmdlProcess; synchronized ( lock ) { System.out.println ( "Ready to execute " + commandLine ); // Create Runtime process to execute command line cmdlProcess = Runtime.getRuntime().exec ( commandLine ); cmdlProcess.waitFor (); System.out.println ( "Done executing... " + commandLine ); } // Get application exit code ( %ERRORLEVEL% on WIN, $? on UNIX ) int returnCode = cmdlProcess.exitValue(); catch ( InterruptedException iE ) { System.out.println ( "Did not process " + commandLine ); }