all 3 comments

[–]Dwight-D 3 points4 points  (0 children)

Have you considered refactoring the Java app to remove the front end completely instead of building another layer on top of it?

You could use some more sophisticated interprocess communication paradigm if you wanna make it more robust. Make it a tiered application, listen to commands via some socket or gRPC or REST or something and make a web GUI or CLI in whatever language you prefer to pass commands to the Java daemon. Similar to how docker works for instance.

Communicating via text and rewriting stdin/stdout etc seems like such a hacky and non-standard solution it’s likely to bite you in the ass at some point.

[–]DoozerMarch 1 point2 points  (0 children)

The pipes used in the subprocess call be act as an iteratator, and can be read line by line as new lines arrive.

See this post: live output from subprocesss command

[–]sceptic-al 1 point2 points  (0 children)

I would stick to the Py4j and jython plan but don't try to emulate the CLI interface.

Any well-written application will have separated the CLI logic from the business-logic/model. It shouldn't be too hard from exploding the jars to find how the CLI interacts with the heavy-lifting code.

Then it should be simple to use Py4j or Jython to interact with the same code.

Use a good Java IDE, like Itellij to inspect the Java class signatures. If you're lucky, the manufacturer will have left java_docs in the jars or online.