使用Runtime.getRuntime().exec( cmdAry );
与一个字符串作为数组相同。
Exeption Cannot run program "libreoffice": error=2, No such file or directory
如果我在终端中输入确切的命令字符串,它就会起作用。
这里是命令字符串:
libreoffice --impress --show /home/xxx/ImpressTests/ShowTestOne.odp
Linux Mint 19.3
相同的 java 程序在 Windows 10 上运行良好。
在 Linux 终端上,程序成功运行后会显示此信息。重新保存文件并不能解决此问题。
xxx@LM19RyzenVM:~/CodeJava$ libreoffice --impress --show /home/xxx/ImpressTests/ShowTestOne.odp
func=xmlSecCheckVersionExt:file=xmlsec.c:line=188:obj=unknown:subj=unknown:error=19:invalid version:mode=abi compatible;expected minor version=2;real minor version=2;expected subminor version=25;real subminor version=26
xxx@LM19RyzenVM:~/CodeJava$
此 libreoffice 错误是否导致失败?这以前有效。我如何找到有关错误的更多信息?这是在 VirtualBox VM 中运行的。这可能有区别吗?我现在去真机测试一下。
谢谢。
最佳答案
我找到了。
https://bugs.documentfoundation.org/show_bug.cgi?id=118373
这是一个已知错误。由于某种原因,Windows 并不关心。但在从 Java 启动的 Linux 上,如果子进程写入 SYSERR,Java 就会将其丢弃。 所以也许我可以将它包装在 Linux 上的一个脚本中来覆盖该错误,直到修复到达。
关于Java Runtime.getRuntime().exec - 没有这样的文件或目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61367943/