Question

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 .

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?

Was it helpful?

Solution 2

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

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

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

Sourced form check out http://forum.openoffice.org/en/forum/viewtopic.php?t=2520

OTHER TIPS

I know it's 7 years late, but I came across this question while trying to solve the same problem; namely compiling and running a short Java program to start and then connect to a headless LibreOffice / OpenOffice process using the Bootstrap.bootstrap() method. 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!' 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; juh.jar, jurt.jar, ridl.jar, unoil.jar and 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.

You didn't specify much info about how you run openoffice/libreoffice but i'll give it a try.

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. We worked with a script that first ran libreoffice and then tried to connect multiple times.

The causes where: - When starting libreoffice (writer) it showed multiple times the same error message that it couldn't find the 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.

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. This was solved by giving the windows service the right credentials.

So before you can connect to libreoffice/openoffice you have to start it with a command. This can run in de background without showing libreoffice on the interface. You have to lookup startup properies of soffice.exe and also make sure its started by the right user.

Try this "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. 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 :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top