Java启动openoffice服务后拒绝连接

qq_34350475 2017-07-04 05:15:36
手动启动是没有问题的,但是如果我用代码启动服务后,报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

报错:java.net.ConnectException: connection failed: socket,host=localhost,port=8100,tcpNoDelay=1: java.net.ConnectException: Connection refused: connect
localhost和127.0.0.1都试过了不行
...全文
2507 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq_39818455 2019-12-31
  • 打赏
  • 举报
回复 1
您好,请问下您有遇到在项目启动时候报A process with acceptString 'socket,host=127.0.0.1,port=8100,tcpNoDelay=1;urp;StarOffice.ServiceManager' started but its pid could not be found这个错误吗
qq_34350475 2017-07-06
  • 打赏
  • 举报
回复
还是自己解决了...通过查找资料发现一个新的包jodconverter-core,其中有个OfficeManager类可以实现另外的连接方式,我的问题是启动一次后,就可以连接,所以刚好可以,只能暂时这样解决了。

51,409

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧