简体   繁体   English

通过 Java 连接到 OpenOffice 时未发现 Office 可执行文件异常

[英]No office executable found exception while connecting to OpenOffice through Java

Using XComponentContext xContext = Bootstrap.bootstrap() , I am trying to get the Get the remote office component context of OpenOffice through Java.But its raising exception no office executable found .使用XComponentContext xContext = Bootstrap.bootstrap() ,我试图通过 Java 获取获取 OpenOffice 的远程办公组件上下文。但是它引发的异常no office executable found

I have specified the path of program directory of OpenOffice in the CLASSPATH, yet i am getting this exception.How can I resolve this problem?我已经在CLASSPATH中指定了OpenOffice的程序目录路径,但出现此异常。如何解决此问题?

I know it's 7 years late, but I came across this question while trying to solve the same problem;我知道已经晚了 7 年,但是我在尝试解决同一问题时遇到了这个问题; namely compiling and running a short Java program to start and then connect to a headless LibreOffice / OpenOffice process using the Bootstrap.bootstrap() method.即编译和运行一个简短的 Java 程序来启动,然后使用 Bootstrap.bootstrap() 方法连接到无头 LibreOffice / OpenOffice 进程。 It would work if compiled and run from within Eclipse but when I tried to do it from the command line I got the 'no office executable found!'如果在 Eclipse 中编译和运行它会工作,但是当我尝试从命令行执行它时,我得到了“找不到办公室可执行文件!” error.错误。 What eventually worked for me was adding the path of the office executable (/usr/lib/libreoffice/program/) to the classpath in addition to the libraries;除了库之外,最终对我有用的是将办公室可执行文件(/usr/lib/libreoffice/program/)的路径添加到类路径中; juh.jar, jurt.jar, ridl.jar, unoil.jar and unoloader.jar. juh.jar、jurt.jar、ridl.jar、unoil.jar 和 unoloader.jar。 It is only necessary to do this when running the program, not when compiling it.只有在运行程序时才需要这样做,编译时不需要。 That is:那是:

To compile:编译:

javac -classpath '.:/usr/lib/libreoffice/program/classes/juh.jar:/usr/lib/libreoffice/program/classes/jurt.jar:/usr/lib/libreoffice/program/classes/ridl.jar:/usr/lib/libreoffice/program/classes/unoil.jar:/usr/lib/libreoffice/program/classes/unoloader.jar' MyProg.java

To run:跑步:

java -classpath '.:/usr/lib/libreoffice/program/:/usr/lib/libreoffice/program/classes/juh.jar:/usr/lib/libreoffice/program/classes/jurt.jar:/usr/lib/libreoffice/program/classes/ridl.jar:/usr/lib/libreoffice/program/classes/unoil.jar:/usr/lib/libreoffice/program/classes/unoloader.jar' MyProg

This worked for me without using any additional tools.这对我有用,而无需使用任何其他工具。

1) Download the bootstrapconnector.jar from http://forum.openoffice.org/en/forum/download/file.php?id=836 1) 从http://forum.openoffice.org/en/forum/download/file.php?id=836下载 bootstrapconnector.jar

2) String oooExeFolder = "C:/Program Files/OpenOffice.org 2.3/program/"; 2) String oooExeFolder = "C:/Program Files/OpenOffice.org 2.3/program/";

3) XComponentContext xContext = BootstrapSocketConnector.bootstrap(oooExeFolder); 3) XComponentContext xContext = BootstrapSocketConnector.bootstrap(oooExeFolder);

Sourced form check out http://forum.openoffice.org/en/forum/viewtopic.php?t=2520来源表格查看http://forum.openoffice.org/en/forum/viewtopic.php?t=2520

You didn't specify much info about how you run openoffice/libreoffice but i'll give it a try.您没有详细说明如何运行 openoffice/libreoffice,但我会尝试一下。

I ran in this exception also recently.我最近也遇到了这个例外。 I believe it was with de latest libreoffice (4.4 ?) and java 7. It worked when i was executing libreoffice by hand and then connecting with Java.我相信它与最新的 libreoffice (4.4 ?) 和 java 7 一起使用。当我手动执行 libreoffice 然后与 Java 连接时,它起作用了。 We worked with a script that first ran libreoffice and then tried to connect multiple times.我们使用的脚本首先运行 libreoffice,然后尝试多次连接。

The causes where: - When starting libreoffice (writer) it showed multiple times the same error message that it couldn't find the java jre.原因如下: - 启动 libreoffice (writer) 时,它多次显示相同的错误消息,即找不到 java jre。 When clicking the message away libreoffice does start and then you can specifie somewhere via menu of libreoffice where to find the jre.当单击消息离开 libreoffice 时,您可以通过 libreoffice 菜单指定在何处找到 jre。

The other problem was file system rights for the windows service starting the script it just didn't execute libreoffice (in background (headless i believe)) and then the JAVA program tryed to connect.另一个问题是 Windows 服务启动脚本的文件系统权限,它只是没有执行 libreoffice(在后台(我相信是无头的)),然后 JAVA 程序尝试连接。 This was solved by giving the windows service the right credentials.这是通过为 Windows 服务提供正确的凭据来解决的。

So before you can connect to libreoffice/openoffice you have to start it with a command.因此,在您可以连接到 libreoffice/openoffice 之前,您必须使用命令启动它。 This can run in de background without showing libreoffice on the interface.这可以在后台运行,而无需在界面上显示 libreoffice。 You have to lookup startup properies of soffice.exe and also make sure its started by the right user.您必须查找 soffice.exe 的启动属性,并确保它由正确的用户启动。

Try this "var xContext = Bootstrap.bootstrap();"试试这个“var xContext = Bootstrap.bootstrap();” if you are using C# There is a known problem with the api (libreoffice 4.0 and the sdk 4.0) with the framework 4.0.如果您使用的是 C# 框架 4.0 的 api(libreoffice 4.0 和 sdk 4.0)存在已知问题。 You could use the api (libreoffice 3.6.6 and the sdk 3.6.6) if your problem persists I don't know if there something similar in java but you can try it anyway :)如果您的问题仍然存在,您可以使用 api(libreoffice 3.6.6 和 sdk 3.6.6)我不知道 java 中是否有类似的东西,但您无论如何都可以尝试:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM