hello, i have been working on this project and wanted to execute FOP from my java application and it stalls when it is executed. it only works when i... 1.) execute it like this: Runtime.getRuntime().exec("java -cp jars" +File.separator+ "fop.jar;jars" +File.separator+ "batik.jar;jars" +File.separator+ "xalan.jar;jars" +File.separator+ "xerces.jar org.apache.fop.apps.Fop temp" +File.separator+ "make_pdf.fo " +target_file.getText()); and after having a piriode of time in between where it does nothing. it takes up to ten times as long as when it is executed by the batchfile and it works perfectly from a batchfile 2.) execute it like this: Runtime.getRuntime().exec("java -cp jars" +File.separator+ "fop.jar;jars" +File.separator+ "batik.jar;jars" +File.separator+ "xalan.jar;jars" +File.separator+ "xerces.jar org.apache.fop.apps.Fop temp" +File.separator+ "make_pdf.fo " +target_file.getText()).waitFor(); and i close the window and with it the main programm and then all of a sudden it finishes and i get the pdf either one is not very fine. i need waitFor() with it and i cannot close the programm i doubt that it lies within my programm because it is just one of many runtimes and it is the only one that doesn't work
I may have some related information on this: When FOP is activated using the static main method, FOP always terminates execution by calling System.exit(x) - even when everything is ok. I suppose this is what causes the problem with exec().
my i mention once again, FOP stalls all of a sudden in the middle of the document it is trying to create. both programms are still in memory and uses around 33MB and when it sometimes finishes it grows up to 66MB. none of the programms are terminated. does someone have a workaround how you could implement this into a java application?
The reason is probably that the stderr (or stdout) buffer is full. FOP writes by default quite a few logging messages. You'll have to read them or otherwise discard them. If the buffer is full,FOP hangs in an attempt to write some log output. If the invoking java application is closed, so are the file handles piping stderr and stdout output, and FOP resumes work. It is recommended not to use exec() for executing FOP, look at the guidelines how to embed FOP directly into your Java application.
batch transition to closed remaining pre-FOP1.0 resolved bugs