You will need to use a ProcessBuilder to create a Process object, or the older method using Runtime.exec().
When you start a Process there are two Streams; I think they represent standard output and standard error, but am not sure, and you have to keep them "empty" by reading their contents as fast as they are filled.
You also have to wait for the Process to finish before using its results.
You can find details by searching the forum for similar posts;
here is one from last year.
Note my quote of
DaConta's classic article from 8 years ago. Note that ProcessBuilder was not available then.
I hope that gives you a hint where to start.