No office executable found exception while connecting to OpenOffice through Java
Asked Answered
F

4

6

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?

Flavory answered 4/1, 2013 at 12:58 Comment(1)
I don't know what the problem can be, but did you read this? forum.openoffice.org/en/forum/viewtopic.php?t=2520 Hope it helpsUnlearned
H
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

Hollishollister answered 29/1, 2013 at 19:51 Comment(1)
this works but include bootstrapconnector with maven: mvnrepository.com/artifact/org.openoffice/bootstrap-connector/…Property
R
5

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.

Raffle answered 14/12, 2019 at 17:59 Comment(1)
Thank u for that useful comment. Will surely try with this when there is upgrade for such existing functionality on the project.Flavory
H
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

Hollishollister answered 29/1, 2013 at 19:51 Comment(1)
this works but include bootstrapconnector with maven: mvnrepository.com/artifact/org.openoffice/bootstrap-connector/…Property
P
0

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.

Paleface answered 4/1, 2013 at 13:20 Comment(1)
Firstly I am having this problem while connecting OpenOffice3.0 with Java and how r u starting soffice.exe through the command pls elaborate further.Flavory
A
0

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 :)

Andalusia answered 26/4, 2013 at 16:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.