Apache OpenOffice (AOO) Bugzilla – Issue 82332
get rid of javaw after OO sdk work is complete
Last modified: 2013-02-24 21:07:42 UTC
With OO SDK I succeed to convert an html file (made with OO) to a pdf file. It works perfectly. The problem is that a javaw.exe task is started in memory (about 8 M), and I cannot get rid of it when I do not need it any more. I presume the javaw starts when I code xContext = ...bootstrap(), but there seems to exist no OO sdk code to stop it. Each time I call my new HtmlToPdf object with xContext... in its constructor, a new javaws starts. To avoid having plenty of javaws in memory, I am forced to find a way to create HtmlToPdf only once, and then call its convert() method each time I need. That is acceptable, but it would be nice to be able to get rid of this javaw, at least at the end of the whole application, by coding something from the OO sdk api. (I searched several hours on the net to find a solution, and tried several close() and dispose() on oDesktop, xMCF, xContext... in addition to xStorable) Thanks. (I intend to use this on Linux at final stage)
mmh that sounds strange. All the methods you have mentioned don't start a javaw process. I can run a Java cleint program and do some document conversion ou tof the box without any javaw process involved. Can you provide a demo example or better or source code as attachment to this issue. I can then try to figure out what going wrong. Or try to use our NetBeans plugin to create a Java UNO client program. And use the the examples from the SDK to extend the generated example with your needed conversion functionality.
Thanks for your proposal. Please find attached my test program (see comments in the source - I encountered another dificulty). I think you are right : the javaw I want to get rid of is in fact my test program's jvm, not OO's. But why does it not disappear when the job is done ?
Created attachment 48791 [details] test case
hi, i have marked the issue as invalid because it is no OO issue. I will take a look into your example as soon as i have time for it. currently i am really busy with and i can take some time. You should try a System.exit to make sure that all UNO objects are gone. We don't have influence on the garbage collector and for example the NB plugin generate a System.exit call at the end as well.
ok, I will investigate more on my side as you say and tell you if I succeed
Well, I have put together the conditions to make the conversion from html to pdf work, in my case. I read that one can ask OO to make this conversion locally or remotly. I am just interested in local conversion, requested by a servlet in an application server (WebSphere CE V2). I had problems when I was copying juh, jurt, ridl, unoil jars inside WEB-INF/lib of the war application. Then I realized that the same conversion, requested by a main program in Eclipse, was working just because I referenced (without copying) the jars in the genuine OO installation. So I modified the geronimo.bat of WebSphere to add ;C:\Program Files\OpenOffice.org 2.3\program\classes to its -Djava.ext.dirs. Doing so immediately cleared all the "bootstrap exception" "$getFactory exception" ... so often isssued by the com.sun.star... api. I noticed also that when the request is made from a servlet, there is no additional javaw.exe created (which exactly suits me) whereas when the request is made from a main, there is of course one jvm created, that does not disappear at the end of the program, unless you code system.exit() as you suggested. So I am happy with this. Two more remarks: - After it had worked some time making plenty of various tests, I suddenly caugth an ErrorCodeException at Job.java:187. By chance I observed that if I quit the OO quick launch in the windows tray, the conversion works again (the OO icon comes back in the tray, and soffice.exe and soffice.bin re-appear in the tasks). I hope this will not occur again ! - I read on the web about OO listening on port 8100, and I spent some time about this, starting OO in listening mode. In fact, when you use the genuine OO jars as I do, you dont have to bother with 8100. It works even if netstat shows no 8100 port.
when you use the office in server mode you should always exit the quick starter and i would recommend to use a separate user directory. The office don't listen automatically on a port but ii can be easy configured to do so, see the DevGuide for example or in the SDK you can find a C++ example. The mechanism is the same in Java. If you have general question related to the API etc. please ask on the dev@api.openoffice.org mailing list.