I developed a command-line utility which needs to be called from a Java GUI application. The team in charge on the Java GUI would like to bind my command-line application to a button in the GUI; the Python application is such that at the time we have no time or interest in rewriting it in Java.
I have no experience whatsoever in Java, so I ask you:
What is the best way to bind a command-line based Python application to a button in a Java-based GUI application?
I am very concerned about exception management (how to tell Java that Python failed).
Thanks.
You should be able to execute a spawned process from Java using Runtime.exec(). Here’s some examples.
Make sure you capture the stdout and stderr (concurrently – see this answer for more details) so you can report on errors. You can capture the exit code of the application, so make sure that the application itself correctly reports errors. The error code would be a more reliable way of detecting errors (I would suspect) thatn parsing the output streams.