Java启动openoffice服务后拒绝连接

手动启动是没有问题的,但是如果我用代码启动服务后,报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

阅读 6.9k
2 个回答

通过查找资料发现一个新的包jodconverter-core,其中有个OfficeManager类可以实现另外的连接方式,我的问题是启动一次后,就可以连接,所以刚好可以,只能暂时这样解决了。

新手上路,请多包涵

报错信息发出来

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题