apache.commons.exec - swallow exception thrown by the executed process?

285 Views Asked by At

I use Apache's commons exec library to run another application from my java code on windows. That other application (tshark) might throw an ugly exception which makes windows pop up "an unhandled win32 exception occured in ..." window. Is there some way to swallow that exception in my java code, so the user won't encounter that window?

1

There are 1 best solutions below

0
On BEST ANSWER

Is there some way to swallow that exception in my java code, so the user won't encounter that window?

Well, not easily.

If tshark/wireshark writes something to stderr when that window you want to get rid of pops up, then you may be able to destroy() the process you just spawned when you detect whatever matching string on stderr (that would get rid of tshark/wireshark entirely, not just of the unwanted window).

Anything else is doable, like automatically closing the error window, but that would require much more work (like for example using JNA to find windows title and closing the tshark/wireshark exception window you want to get rid of).