Hi all,
I'm trying to enable command-line processing within a Java application to automate certain events whenever command-line arguments as passed into the application.
There are two applications which are executing,
management and
reports. The idea is to allow the management software to launch the reports software with command-line arguments, which will then automatically generate a report and store the result on the file-system. Seems simple enough.
I've managed to piece together code to accomplish this (the command-line arguments which are passed into the reports Java application are not always the same, thus this cannot be accomplish via script.) It looks something like this:
ProcessBuilder processBuilder = new ProcessBuilder(
"/path/to/javaw",
"-Djava-library.path=.",
"-jar",
"/path/to/jar/file"
);
processBuilder.directory("/path/to/jar/directory");
processBuilder.command().add("/auto");
processBuilder.command().add("someParameter");
processBuilder.start();
This works fine, launching the reports Java application and running through the command-line processing algorithm.
What I'm finding, however, is that the reports Java application is
suspended until the launching management Java application is shutdown. Only then does the reports Java application continue processing as it should.
I believe it has something to do with loading library dependencies. After putting in an enormous collection of debug statements, I've come to realise that the reports application suspends when it comes to loading a Jasper Reports library. The application freezes, and when management is shutdown the library is loaded and continues.
Can anyone think of a reason why this might behave this way? I can confirm that launching the reports JAR file directly using javaw works fine, and reports are created. It's just when launching through this methodology that the application hangs until the management javaw process has exited.
Thanks in advance!