Tiada masalah jika saya memulakannya secara manual, tetapi jika saya memulakan perkhidmatan menggunakan kod, ralat ditolak sambungan dilaporkan
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();
Anda boleh mencetak kandungan sambungan, tetapi ralat akan dilaporkan semasa menyambung kemudian
kandungan starOpenoffice.bat:
soffice -tanpa kepala -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard
Kaedah permulaan manual:
cd C:Program Files (x86)OpenOffice4program
soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard
Mesej ralat dihantar