Gikar Gikar - 4 months ago 32
Java Question

Start and Stop OpenOffice Service using Java code?

I have OpenOffice installed on both a Windows and a Linux machine. I want to write a simple Java application that will connect to OpenOffice remotely and do some file conversion. I want to run OpenOffice as a service on both Windows and Linux on some random port. After the file conversion is done, I want to stop the service.

Answer

You need to start first :

soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard

then use some library to connect and use the service like jodconverter

To call an executable from java :

Process process = new ProcessBuilder("C:\\PathToExe\\MyExe.exe","param1","param2").start();

You gave him your path to openoffice exe, then each parameter (-headless...)

more infos in runtime.exec