手動啟動是沒有問題的,但是如果我用程式碼啟動服務後,報connection refused錯誤
public static String soffice_host = "127.0.0.1";
public static String soffice_port = "8100";
public static Process pro = null;
String commands = "cmd.exe /C C:\Program Files (x86)\OpenOffice4\program\startOpenoffice.bat";
System.out.println(commands);
pro = Runtime.getRuntime().exec(commands);
connection = new SocketOpenOfficeConnection(soffice_host,Integer.parseInt(soffice_port));
System.out.println("获得连接"+connection);
connection.connect();
可以列印出連接connection的內容,但之後連線的時候報錯
starOpenoffice.bat內容:
soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard
手動啟動方法:
cd C:\Program Files (x86)\OpenOffice4\program
soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard