[Java solution] "no office executable found!"

Java, C++, C#, Delphi... - Using the UNO bridges
hol.sten
Volunteer
Posts: 495
Joined: Mon Oct 08, 2007 1:31 am
Location: Hamburg, Germany

[Java solution] "no office executable found!"

Post by hol.sten »

Introduction
This is a short How-To for quickly solving the regularly occurring error "no office executable found!". You can read a huge number of threads in various OpenOffice.org forums dealing with this problem. This error is caused by using the Bootstrap Connection Mechanism (introduced with OOo 2.x) in conjunction with moving or copying "juh.jar" (OOo's "Java UNO Helper" JAR file containing the class file "Bootstrap.class") from the subfolder "program\classes" of the OOo installation folder (which is for example on Windows "c:\program files\OpenOffice.org 2.3") to another folder (mostly a subfolder, which is directly accessible from a web container or web server like for example Tomcat).

How-to
So, if you're encountering "no office executable found!" follow these steps:
  1. Download the file "bootstrapconnector.jar" attached to this post and save it.
  2. Put the JAR file "bootstrapconnector.jar" for example in the same folder, where you put "juh.jar", and add it to your CLASSPATH or add it in your IDE to the libraries for source code compiling (for example open in NetBeans the project properties and select there "Libraries" > tab "Compile" > press "Add JAR/Folder" > locate the "bootstrapconnector.jar" and press "Open").
  3. Determine the folder of your OpenOffice.org executable "soffice.exe" (on Windows systems) or "soffice" (on *nix systems). On Windows it might be something like "c:\program files\OpenOffice.org 2.3\program\", and on *nix for example something like "/opt/openoffice.org2.3/program" or "/usr/lib/openoffice.org/program".
  4. Edit your Java source code file, that tries to get the connection by calling "Bootstrap.bootstrap()". This is mostly done with a Java source code line looking like this:

    Code: Select all

    XComponentContext xContext = Bootstrap.bootstrap();
    Perform the following steps in this Java source file:
  5. [list=a]
  6. Add the following line to your import statements:

    Code: Select all

    import ooo.connector.BootstrapSocketConnector;
  7. Add a line above "Bootstrap.bootstrap()" to assign the name of the folder of your OpenOffice.org executable to a String variable:

    Code: Select all

    String oooExeFolder = "C:/Program Files/OpenOffice.org 2.3/program/";
  8. Change the call of "Bootstrap.bootstrap()" to "BootstrapSocketConnector.bootstrap(oooExeFolder)":

    Code: Select all

    XComponentContext xContext = BootstrapSocketConnector.bootstrap(oooExeFolder);
  9. Save and compile the edited file and see if "no office executable found!" has really vanished.
[*]If you want to learn more about what you can do with "bootstrapconnector.jar", stay tuned. (To be continued...)[/*][/list]

Credits
Most of the source code in the attached JAR file has been taken from the Java class "Bootstrap.java" (Revision: 1.15) from the UDK projekt (Uno Software Development Kit) from OpenOffice.org (http://udk.openoffice.org/). The source code is available for example through a browser based online version control access at http://udk.openoffice.org/source/browse/udk/. The Java class "Bootstrap.java" is there available at http://udk.openoffice.org/source/browse ... iew=markup

The idea to develop the BootstrapConnector, BootstrapSocketConnector and BootstrapPipeConnector comes from the blog "Getting started with the OpenOffice.org API part III : starting OpenOffice.org with jars not in the OOo install dir by Wouter van Reeven" (http://technology.amis.nl/blog/?p=1284) and from various posts in the "(Unofficial) OpenOffice.org Forum" at http://www.oooforum.org/ and this forum complaining about "no office executable found!".

Maven/Github
The BootstrapConnector has been made available via Maven and Github by jeremysolarz The dependency can be included like this:

Code: Select all

<dependency>
    <groupId>com.github.jeremysolarz</groupId>
    <artifactId>bootstrap-connector</artifactId>
    <version>1.0.0</version>
</dependency>
Read the post of jeremysolarz on this topic here: viewtopic.php?p=418100#p418100.

Jar file (attached as ZIP file)
The Jar file of the BootstrapConnector is still available here:
Attachments
bootstrapconnector.jar
The JAR file "bootstrapconnector.jar" contains several class and source files and a Java example using the BootstrapSocketConnector class.
(15.95 KiB) Downloaded 17028 times
Last edited by hol.sten on Mon May 29, 2017 2:56 pm, edited 4 times in total.
OOo 3.2.0 on Ubuntu 10.04 • OOo 3.2.1 on Windows 7 64-bit and MS Windows XP
hol.sten
Volunteer
Posts: 495
Joined: Mon Oct 08, 2007 1:31 am
Location: Hamburg, Germany

Change log

Post by hol.sten »

10. Apr 2008: bootstrapconnector.zip to bootstrapconnector.jar renamed
10. Feb 2008: Creation of Java solution
Last edited by hol.sten on Thu Apr 10, 2008 9:51 pm, edited 1 time in total.
OOo 3.2.0 on Ubuntu 10.04 • OOo 3.2.1 on Windows 7 64-bit and MS Windows XP
ggraham412
Posts: 5
Joined: Mon Feb 25, 2008 10:12 pm

Re: [Java solution] "no office executable found!"

Post by ggraham412 »

Thank you so much for this, it worked as specified.

(But for me, I used backwards slash windows path convention in step 4b.)
hol.sten
Volunteer
Posts: 495
Joined: Mon Oct 08, 2007 1:31 am
Location: Hamburg, Germany

Re: [Java solution] "no office executable found!"

Post by hol.sten »

ggraham412 wrote:I used backwards slash windows path convention in step 4b.
But it does work with slashs, too? I wrote and tested everything in this thread on Windows XP and never had a problem with slashs.
OOo 3.2.0 on Ubuntu 10.04 • OOo 3.2.1 on Windows 7 64-bit and MS Windows XP
mbacyrille2002
Posts: 1
Joined: Mon Feb 25, 2008 5:27 pm

Re: [Java solution] "no office executable found!"

Post by mbacyrille2002 »

Good morning,

The sample is not work when I test it.

The execution is shut down in this instruction :
XComponentContext remoteContext = BootstrapSocketConnector.bootstrap(OOO_EXEC_FOLDER);

Please canyou help me?
hol.sten
Volunteer
Posts: 495
Joined: Mon Oct 08, 2007 1:31 am
Location: Hamburg, Germany

Re: [Java solution] "no office executable found!"

Post by hol.sten »

mbacyrille2002 wrote:The sample is not work when I test it.

The execution is shut down in this instruction :
XComponentContext remoteContext = BootstrapSocketConnector.bootstrap(OOO_EXEC_FOLDER);

Please canyou help me?
Please read the Survival Guide for the forum. Start with telling me which OOo version, which operating system, which IDE and which java version you are using. Tell me what you tried. Which steps you made and which exception you get. Otherwise I cannot help you.
OOo 3.2.0 on Ubuntu 10.04 • OOo 3.2.1 on Windows 7 64-bit and MS Windows XP
ggraham412
Posts: 5
Joined: Mon Feb 25, 2008 10:12 pm

Re: [Java solution] "no office executable found!"

Post by ggraham412 »

Yes, now that you mention it, I just checked and it works for me with forward slashes too. Sorry for the miscommunication: I've been burned on this before and thought it was useful to mention. (Still working for me, by the way... )
charlesvc
Posts: 10
Joined: Thu Mar 13, 2008 4:48 pm

Re: [Java solution] "no office executable found!"

Post by charlesvc »

Hol.sten,

I tested with your jar file, but failed. And i have one query now to you:- that how can we update port as 8100, there is no server right, i am executing in tomcat and taking instance from my system, so how can i use socket connection instead of pipe connection.

Kindly requested to revert back with a solution
charlesvc
Posts: 10
Joined: Thu Mar 13, 2008 4:48 pm

Re: [Java solution] "no office executable found!"

Post by charlesvc »

Hi Hol.sten,

Kindly request to see my posts and messages and give some priority
charlesvc
Posts: 10
Joined: Thu Mar 13, 2008 4:48 pm

Re: [Java solution] "no office executable found!"

Post by charlesvc »

Hi hol.sten,

When i am trying to get the soffice start from web application to convert word to pdf, actually when i look into taskmanager, both soffice.bin and soffice.exe are running, but no window is opening and not converting to pdf.

Kindly requested to revert back with a positive reply as if this error resolved, our project going to complete. So I humbly request you to provide me with a solution.

Thanking you
Charles v c
hol.sten
Volunteer
Posts: 495
Joined: Mon Oct 08, 2007 1:31 am
Location: Hamburg, Germany

Re: [Java solution] "no office executable found!"

Post by hol.sten »

charlesvc wrote:how can i use socket connection instead of pipe connection.
The JAR file I provide above contains, beside some other files, the BootstrapSocketConnector. All you have to do is to change your code as I wrote down above (change Bootstrap.bootstrap() to BootstrapSocketConnector.bootstrap(...)). That's all. If you still encounter problems check the name of your folder of the OOo installation containing the soffice executable.

And if you prefer a pipe connection, use the BootstrapPipeConnector instead.
OOo 3.2.0 on Ubuntu 10.04 • OOo 3.2.1 on Windows 7 64-bit and MS Windows XP
charlesvc
Posts: 10
Joined: Thu Mar 13, 2008 4:48 pm

Re: [Java solution] "no office executable found!"

Post by charlesvc »

I changed as you told, but not working from all versions of apache tomcat, but successfully worked from jakarta-tomcat. So, May i know what is the exact problem. somebody told me to update classpath at runtime i did so using system.setproperty(), but failed again. Ceasing here wishing to hear from you.

Thanking you
Charles v c
JMysak
Posts: 6
Joined: Tue May 06, 2008 4:09 pm

Re: [Java solution] "no office executable found!"

Post by JMysak »

I get the following error when trying to use the bootstrap jar you provided...

java.lang.UnsupportedClassVersionError: Bad version number in .class file

I am using Java 1.5.0_13 on MacOS 10.5. Any chance you compiled your code with Java 1.4.2 or something other than 5.0?
JMysak
Posts: 6
Joined: Tue May 06, 2008 4:09 pm

Re: [Java solution] "no office executable found!"

Post by JMysak »

Just checked your MANIFEST (and answered my own question). Looks like you compiled with 1.5.0_14.

In any case, I just noticed you included the src in the jar (thanks!). I'll recompile and see if that resolves my issue.
JMysak
Posts: 6
Joined: Tue May 06, 2008 4:09 pm

Re: [Java solution] "no office executable found!"

Post by JMysak »

Works for me after recompiling. Thanks!

Code: Select all

Connected to a running office ...
remote ServiceManager is available
hol.sten
Volunteer
Posts: 495
Joined: Mon Oct 08, 2007 1:31 am
Location: Hamburg, Germany

Re: [Java solution] "no office executable found!"

Post by hol.sten »

JMysak wrote:Works for me after recompiling. Thanks!

Code: Select all

Connected to a running office ...
remote ServiceManager is available
Thanks for the affirmation! Good to know the old trick from an old movie worked for you: "Use the source, Luke" ;-)
OOo 3.2.0 on Ubuntu 10.04 • OOo 3.2.1 on Windows 7 64-bit and MS Windows XP
ggraham412
Posts: 5
Joined: Mon Feb 25, 2008 10:12 pm

Re: [Java solution] "no office executable found!"

Post by ggraham412 »

Hi,

I've written a short example program using the bootstrapconnector.jar that uses Open Office to convert input office documents to PDF, and optionally uses Ghostscript to merge the output. The code is available with a short article here: http://www.codeproject.com/KB/java/PDFCM.aspx. If you like it, please give it a plug. (If not, please take the time to explain why. ;)

Thanks again for the bootstrapconnector.jar- It saved this newbie many hours!

-Greg
thehl
Posts: 1
Joined: Thu Jun 26, 2008 4:43 pm

Re: [Java solution] "no office executable found!"

Post by thehl »

I'm having some kind of version error on the jar file. Can I get the source code for this, please?

Thanks.
OOo 2.4.X on Ms Windows XP + Redhat Linux, Ubuntu
hol.sten
Volunteer
Posts: 495
Joined: Mon Oct 08, 2007 1:31 am
Location: Hamburg, Germany

Re: [Java solution] "no office executable found!"

Post by hol.sten »

thehl wrote:I'm having some kind of version error on the jar file. Can I get the source code for this, please?
Download bootstrapconnector.jar from the first post of this thread. To ease version errors and other problems I put the class files and the source code into that jar file.
OOo 3.2.0 on Ubuntu 10.04 • OOo 3.2.1 on Windows 7 64-bit and MS Windows XP
Hardie82
Posts: 5
Joined: Fri Oct 24, 2008 3:08 pm

Re: [Java solution] "no office executable found!"

Post by Hardie82 »

Hi. I want to develop a web-application which creates doc-/pdf-reports from analysed excelfiles. Therefore I've decided to use the oo-api and got it running as a stand-alone application. Now I wanted to transfer it to a web-application and got the described problem with this exception. After reading this thread I included the jar-file. But using the bootstrap-method there is a difference between the code in this thread an the method from BootstrapConnector-class. In the method there are three parameters required. Were there some changes to the class and what's about the other two parameters? By the way I am using Tomcat 6, Eclipse 3.4 and OO 2.4.

Regards
Hardie
OOo 2.3.X on Ms Windows XP
Hardie82
Posts: 5
Joined: Fri Oct 24, 2008 3:08 pm

Re: [Java solution] "no office executable found!"

Post by Hardie82 »

If I tried to use the following code I got a StackOverflowError:

String ooExeFolder = "C:\\Programme\\OpenOffice.org 2.4\\program\\";
this.xContext = BootstrapConnector.bootstrap(ooExeFolder, "", "");
XMultiComponentFactory xMCF = this.xContext.getServiceManager();
this.xCLoader = (XComponentLoader)UnoRuntime.queryInterface(XComponentLoader.class, xMCF.createInstanceWithContext("com.sun.star.frame.Desktop", this.xContext));
OOo 2.3.X on Ms Windows XP
hol.sten
Volunteer
Posts: 495
Joined: Mon Oct 08, 2007 1:31 am
Location: Hamburg, Germany

Re: [Java solution] "no office executable found!"

Post by hol.sten »

Hardie82 wrote:After reading this thread I included the jar-file. But using the bootstrap-method there is a difference between the code in this thread an the method from BootstrapConnector-class.
That depends on you! You can use the JAR as I wrote in the first example in this thread:

Code: Select all

XComponentContext xContext = BootstrapSocketConnector.bootstrap(oooExeFolder);
Or you can use the bootstrap-method with three parameters. If you want to know what the other two parameters are for, take a look into the JAR file: It contains the whole source code with some comments.
Hardie82 wrote:In the method there are three parameters required.
My advice: Use the method from the example with just one parameter!
Hardie82 wrote:Were there some changes to the class
No.
Hardie82 wrote:and what's about the other two parameters?
As said above: Take a look into the JAR file: It contains the whole source code with some comments.
Hardie82 wrote:If I tried to use the following code I got a StackOverflowError:

String ooExeFolder = "C:\\Programme\\OpenOffice.org 2.4\\program\\";
First: Use this instead:

Code: Select all

String oooExeFolder = "C:/Programme/OpenOffice.org 2.4/program/";
The example from the first post in this tread is working on Windows without double backslashes.
Hardie82 wrote:this.xContext = BootstrapConnector.bootstrap(ooExeFolder, "", "");
Second: Use this much simpler code from the first post in this tread instead:

Code: Select all

XComponentContext xContext = BootstrapSocketConnector.bootstrap(oooExeFolder);
Or take a look into the JAR file and use the appropriate parameters.
OOo 3.2.0 on Ubuntu 10.04 • OOo 3.2.1 on Windows 7 64-bit and MS Windows XP
Hardie82
Posts: 5
Joined: Fri Oct 24, 2008 3:08 pm

Re: [Java solution] "no office executable found!"

Post by Hardie82 »

After using the BoostrapSocketConnector all works fine. Thanks a lot. But there is still a question. After writing my document and saving it to disk the oo-process is still alive. Is there a way to stop it?
OOo 2.3.X on Ms Windows XP
hol.sten
Volunteer
Posts: 495
Joined: Mon Oct 08, 2007 1:31 am
Location: Hamburg, Germany

Re: [Java solution] "no office executable found!"

Post by hol.sten »

Hardie82 wrote:After using the BoostrapSocketConnector all works fine. Thanks a lot.
That was the reason for providing the example with BoostrapSocketConnector in the first post of this thread ;-)
Hardie82 wrote:But there is still a question. After writing my document and saving it to disk the oo-process is still alive. Is there a way to stop it?
As long as you don't terminate OOo, that process keeps running. Terminating OOo stops your process, too.
OOo 3.2.0 on Ubuntu 10.04 • OOo 3.2.1 on Windows 7 64-bit and MS Windows XP
Hardie82
Posts: 5
Joined: Fri Oct 24, 2008 3:08 pm

Re: [Java solution] "no office executable found!"

Post by Hardie82 »

Ahh, okay. Is there the possibility to open one time a process and reuse this process without starting a new one? So I only have one oo-process running?

BTW: how do I terminate an oo-process?
OOo 2.3.X on Ms Windows XP
hol.sten
Volunteer
Posts: 495
Joined: Mon Oct 08, 2007 1:31 am
Location: Hamburg, Germany

Re: [Java solution] "no office executable found!"

Post by hol.sten »

Hardie82 wrote:Is there the possibility to open one time a process and reuse this process without starting a new one? So I only have one oo-process running?
Sure, that is possible. Write your own OOoService which starts OOo and does all the stuff you need OOo for (like a document conversion) and call it whenever you need it. Call it for example through a synchroniced method to serialize all of OOo's actions.
Hardie82 wrote:BTW: how do I terminate an oo-process?
Take a closer look at these threads for example:
OOo 3.2.0 on Ubuntu 10.04 • OOo 3.2.1 on Windows 7 64-bit and MS Windows XP
hbagchi
Posts: 3
Joined: Mon Oct 27, 2008 7:41 am

Re: [Java solution] "no office executable found!"

Post by hbagchi »

While things are working as explained here, I see the open office UI window popping up every time when I use
either the convertWithStaticConnector() or the convertWithConnector() method in the attached example BootstrapSocketConnectorExample. I have provided additional options like -headless. Still the oo UI window is popping up every time I fire a conversion. Moreover, with the convertWithStaticConnector() method once the window opens up it stays that way and does not close as it does for the other option. Although, if I use the JODConverter 2.2.1 library and start openoffice as a service with the headless options, no UI window is popping up.
Of course the latest released version of JODConverter does not support the docx format.

Any idea what is going wrong?

Cheers,
Hitesh
OOo 3.0.X on Ms Windows XP
jeffpk
Posts: 18
Joined: Fri Oct 31, 2008 5:43 pm

Re: [Java solution] "no office executable found!"

Post by jeffpk »

Hi,

Im trying to use this to get the Netbenas plugin to work on mac OSX 10.5

It got rid of my big exception trace, but I still ge this error on run of the skeleton prgoram:

com.sun.star.lib.loader.Loader::getCustomLoader: exec unoinfo: java.io.IOException: Cannot run program "${office.program.dir}/unoinfo": error=2, No such file or directory

Any idea what might be causing that??
OOo 3.0.X on Mac OSx Leopard
hol.sten
Volunteer
Posts: 495
Joined: Mon Oct 08, 2007 1:31 am
Location: Hamburg, Germany

Re: [Java solution] "no office executable found!"

Post by hol.sten »

jeffpk wrote:Im trying to use this to get the Netbenas plugin to work on mac OSX 10.5

It got rid of my big exception trace, but I still ge this error on run of the skeleton prgoram:

com.sun.star.lib.loader.Loader::getCustomLoader: exec unoinfo: java.io.IOException: Cannot run program "${office.program.dir}/unoinfo": error=2, No such file or directory

Any idea what might be causing that??
Reading this thread http://user.services.openoffice.org/en/ ... 20&t=11555, you got it working?
OOo 3.2.0 on Ubuntu 10.04 • OOo 3.2.1 on Windows 7 64-bit and MS Windows XP
zebulon
Posts: 3
Joined: Thu Nov 06, 2008 7:18 pm

Re: [Java solution] "no office executable found!"

Post by zebulon »

I am having problems getting rid of the error, perhaps someone could help me. When using the method described here my code works fine in Eclipse, but does not work when I deploy my code to Tomcat 6. I am currently using Fedora 9 and OpenOffice 2.4. Does anyone have any advice?
OOo 2.4.X on Fedora 9
Post Reply