openOffice 自启动
openOffice 不知为何总是自己关闭,宕机,暂时没找的好的解决方案,所以让openOffice 自启动
windows 启动openOffice代码
// 启动OpenOffice的服务
Process pro = Runtime.getRuntime().exec(“C:\Program Files (x86)\OpenOffice 4\program\soffice -
headless - accept=“socket,host=127.0.0.1,port=8100;urp;” -nofirststartwizard”);
// connect to an OpenOffice.org instance running on port 8100
//获取连接
//等待openOffice启动 1秒不行
Thread.sleep(1500);
OpenOfficeConnection connections = new SocketOpenOfficeConnection(127.0.0.1, 8100);
connections.connect();
// convert
DocumentConverter converter = new StreamOpenOfficeDocumentConverter(connections);
converter.convert(file, pdfFile);
// close the connection
connections.disconnect();
// 关闭OpenOffice服务的进程
pro.destroy();