java连接远程服务器上的OpenOffice被拒绝 connection failed

在网上搜了一大堆,启动方式都是:

soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard &

这种方式启动只能本地连接。


如果想通过java远程连接OpenOffice,

##在启动OpenOffice时,将host=的ip地址写为0.0.0.0就可以通过java远程连接了

QQ截图20190117131519.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
		}
	}

QQ截图20190117131406.png

连接成功`~~~~~~

猜你喜欢

转载自blog.csdn.net/weixin_42551369/article/details/87893891