Yogi kurnia
Yogi kurnia

Reputation: 21

error calling c++ from java program

I want to call a c++ executable from a java program. But after I call it, nothing happens. Then after I close the program, there an error window appears, which says abnormal program termination.

The code looks like this :

    try {
            Runtime rt = Runtime.getRuntime();
            Process p = rt.exec("discretize.exe");


        } catch (Exception exc) {/*handle exception*/
            exc.printStackTrace();
        }

and the windows error that appears look like this :

http://dc532.4shared.com/img/8e2-xhaG/debug.PNG

Upvotes: 1

Views: 126

Answers (2)

Yogi kurnia
Yogi kurnia

Reputation: 21

Finally I found the answer.

The problem was the command prompt didn't show up. So after searching google, I found a tip that suggested I simply put:

cmd /c start

before the path of the file. So I changed my code to look like this:

Process myProcess = Runtime.getRuntime().exec("cmd /c start D:\A_TA\KODINGAN\TA\src\discretize.exe");

.. and voila, the command prompt shows!

Upvotes: 1

user1283885
user1283885

Reputation: 1263

I would try doing this below as found from this site: http://www.boards.ie/vbulletin/showthread.php?t=218960

Example:

Process myProcess = Runtime.getRuntime().exec("path to exe");

Upvotes: 0

Related Questions