Java - executing external exe file -


i have executable program made on c++ (cf.exe) takes parameters few text files (.txt), performs calculations, , creates file results (results.txt). program needs no interaction. once executed, when calculations done, it's automatically closed.

then, have other program made on java, contains button executes cf.exe. when button pressed following method called:

    public void executeexternalprogram(){                string filepath = "c++" + file.separator + "cf.exe";         try {                        system.out.println("executing c++ exe...");             process p = runtime.getruntime().exec(filepath);;                    } catch (exception e) {             e.printstacktrace();         }            } 

i don't error, cf.exe not being executed when press button. when execute manually cf.exe, results file correctly created. furthermore, i've tried copy other programs, such notepad.exe, same folder , execute through java without problem. can see why it's not working?

i found changing command given process makes work correctly. change following:

process p = runtime.getruntime().exec("cmd /c start "+ filepath); 

then, updated code method called when button pushed:

public void executeexternalprogram(){            string filepath = "c++" + file.separator + "cf.exe";     try {                    system.out.println("executing c++ exe...");         process p = runtime.getruntime().exec("cmd /c start "+ filepath);     } catch (exception e) {         e.printstacktrace();     }        } 

Comments

Popular posts from this blog

AbotX : How do you create a parallel crawler that stays on and can be added to at run time from new requests -

testing - Detect whether test has failed within fixture -

android - Create single AAR file from multiple modules using Gradle -