java连接远程服务器上的OpenOffice被拒绝 conn
2019-01-17 本文已影响0人
T_zw
在网上搜了一大堆,启动方式都是:
soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard &
这种方式启动只能本地连接。
如果想通过java远程连接OpenOffice,
在启动OpenOffice时,将host=的ip地址写为0.0.0.0就可以通过java远程连接了
![](https://img.haomeiwen.com/i8230644/7dd4ae2f07fc1d52.png)
然后通过java程序去连接:
依赖:
<dependency>
<groupId>com.artofsolving</groupId>
<artifactId>jodconverter</artifactId>
<version>2.2.1</version>
</dependency>
@Test
public void conn() {
OpenOfficeConnection connection=new SocketOpenOfficeConnection("192.168.25.174",8100);
try {
System.err.println("开启连接");
connection.connect();
System.err.println("连接成功");
} catch (Exception e) {
String string=e.getMessage();
System.out.println("连接失败");
System.err.println(string);
// TODO: handle exception
}
}
![](https://img.haomeiwen.com/i8230644/f1e4af69aab852d5.png)
连接成功`~~~~~~