[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

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

Post by hol.sten »

zebulon wrote: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?
Post your exception, some code (at least some code around your exception), and tell us, which of OOo's JARs and which other JAR files you deploy where in Tomcat. Otherwise I can give no further advice.
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 »

Here's the code:

Code: Select all

private void getContext() {
		try {
			String oooExeFolder = "/usr/lib/openoffice.org/program/";
			this.context = BootstrapSocketConnector.bootstrap(oooExeFolder);
		    if(context == null) {
		    	System.err.println("ERROR: Could not bootstrap default Office.");
		    }
		} catch(BootstrapException e) {
		    e.printStackTrace();
		    System.exit(1);
		}
    }
The error happens on this.context = BootstrapSocketConnector.bootstrap(oooExeFolder)
The error I get is:

Code: Select all

com.sun.star.comp.helper.BootstrapException: no office executable found!
This is all part of a servlet that is going to use Impress, so this is part of code to do that. The code all runs perfectly in Eclipse, but still fails when the war file is deployed to Tomcat 6.
OOo 2.4.X on Fedora 9
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 »

zebulon wrote:The code all runs perfectly in Eclipse, but still fails when the war file is deployed to Tomcat 6.
You still haven't told which JAR files you use and deploy.

Anyway, for whatever reason, something goes wrong. So the next step I would take is to debug the application. My bootstrapconnector.jar contains all the source code, too. So it should be possible to remote debug your application running in Tomcat from Eclipse. Doing this, you should take a closer look at the OOoServer.start() method. There you'll find the lines

Code: Select all

if (fOffice == null)
    throw new BootstrapException("no office executable found!");
where your exception occurs.
OOo 3.2.0 on Ubuntu 10.04 • OOo 3.2.1 on Windows 7 64-bit and MS Windows XP
zoharat
Posts: 18
Joined: Tue Dec 02, 2008 7:19 pm

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

Post by zoharat »

Once you connect to OpenOffice to perform your conversions how do we disconnect when the server shuts down?

Sometimes my files get locked and I cannot delete them. I have to manually go into task maanger and shut down soffice.bin and then I can delete the files.
OOo 3.0.X on Ms Windows XP + Red Hat Linux
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 »

zoharat wrote:Once you connect to OpenOffice to perform your conversions how do we disconnect when the server shuts down?
There is no disconnect available. And even if OOo should offer something like this, you might not be able to call it, after the server shut down.
zoharat wrote:Sometimes my files get locked and I cannot delete them. I have to manually go into task maanger and shut down soffice.bin and then I can delete the files.
If the soffice.bin process is still running, it didn't shut down. Although it happens from time to time, that soffice.bin stops processing function calls which you named here shutting down. But ok, this is just wording, and not very helpful for you ;-)

Anyway, you're totally right: OOo causes trouble from time to time. Sometimes it shuts down completely, so there is no longer a soffice.bin process running, and you should have no problems with deleting your files. And sometimes OOo stops responding and blocks every further function call. If this happens, I simply kill OOo the hard way. Some time ago I posted an OOo killer class here http://www.oooforum.org/forum/viewtopic ... 9186#59186. And for simplicity here is that code again:

Code: Select all

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class KillOpenOffice
{
    /**
    * Kill OpenOffice.
    *
    * Supports Windows XP, Solaris (SunOS) and Linux.
    * Perhaps it supports more OS, but it has been tested
    * only with this three.
    *
    * @throws IOException  Killing OpenOffice didn't work
    */
    public static void killOpenOffice() throws IOException
    {
       String osName = System.getProperty("os.name");
       if (osName.startsWith("Windows"))
       {
          windowsKillOpenOffice();
       }
       else if (osName.startsWith("SunOS") || osName.startsWith("Linux"))
       {
          unixKillOpenOffice();
       }
       else
       {
          throw new IOException("Unknown OS, killing impossible");
       }
    }

    /**
    * Kill OpenOffice on Windows XP.
    */
    private static void windowsKillOpenOffice() throws IOException
    {
       Runtime.getRuntime().exec("tskill soffice");
    }

    /**
    * Kill OpenOffice on Unix.
    */
    private static void unixKillOpenOffice() throws IOException
    {
       Runtime runtime = Runtime.getRuntime();

       String pid = getOpenOfficeProcessID();
       if (pid != null)
       {
          while (pid != null)
          {
             String[] killCmd = {"/bin/bash", "-c", "kill -9 "+pid};
             runtime.exec(killCmd);

             // Is another OpenOffice prozess running?
             pid = getOpenOfficeProcessID();
          }
       }
    }

    /**
    * Get OpenOffice prozess id.
    */
    private static String getOpenOfficeProcessID() throws IOException
    {
       Runtime runtime = Runtime.getRuntime();

       // Get prozess id
       String[] getPidCmd = {"/bin/bash", "-c", "ps -e|grep soffice|awk '{print $1}'"};
       Process getPidProcess = runtime.exec(getPidCmd);

       // Read prozess id
       InputStreamReader isr = new InputStreamReader(getPidProcess.getInputStream());
       BufferedReader br = new BufferedReader(isr);

       return br.readLine();
    }
}
You can find more about the Windows tskill command, that I used in the OOo killer class here http://technet.microsoft.com/en-us/libr ... 90806.aspx for example.
OOo 3.2.0 on Ubuntu 10.04 • OOo 3.2.1 on Windows 7 64-bit and MS Windows XP
zoharat
Posts: 18
Joined: Tue Dec 02, 2008 7:19 pm

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

Post by zoharat »

If I use the boostrapConnector.disconnect method , it kills the soffice.exe. Not the soffice.bin process.

Besides killing it directly is there any other way to stop the soffice.bin process.
OOo 3.0.X on Ms Windows XP + Red Hat Linux
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

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

Post by Villeroy »

zoharat wrote:If I use the boostrapConnector.disconnect method , it kills the soffice.exe. Not the soffice.bin process.

Besides killing it directly is there any other way to stop the soffice.bin process.
http://user.services.openoffice.org/en/ ... =20#p52442
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Louis Botterill
Posts: 9
Joined: Thu Dec 04, 2008 12:02 pm

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

Post by Louis Botterill »

Hi,

I've recently used the BootstrapSocketConnector with success for a web app - I've tried it on both Windows XP and OpenSolaris 10 (101b) and it worked just fine. However, when I tried it on Linux I get an error.

I'm using OpenOffice 3.0 latest
CentOs 5.2 32 bit fully updated
Sun Java 6.0

This class is useful to me because I need to connect from a webapp. In my webapp I package all the OO jars supplied as normal in the SDK into my war and rely on none from the host platform.

I've set my UNO_PATH env variable. Unlike OpenSolaris 10 on Linux I seemed to have two path choices, but I've tried with both, with the same results. These being:

export UNO_PATH=/opt/openoffice.org/basis3.0/program/
export UNO_PATH=/opt/openoffice.org3/program/

I've bounced tomcat (in my case) whenever I've changed any env variables and I know the webapp is reading them ok and passing to the BootstrapSocketConnector constructor.

The error I get is an exception with the message "null" - as far as I can tell, the stack trace is:

com.sun.star.comp.helper.BootstrapException
at ooo.connector.BootstrapConnector.connect(BootstrapConnector.java:129)
at ooo.connector.BootstrapSocketConnector.connect(BootstrapSocketConnector.java:68)
at ooo.connector.BootstrapSocketConnector.connect(BootstrapSocketConnector.java:45)
at ooo.connector.BootstrapSocketConnector.bootstrap(BootstrapSocketConnector.java:82)
...

I realise the jar has source, so I will endeavour to add some more logging or debug if possible - but I'd really like to get this working asap so if anyone has any ideas then I'd really appreciate them. Failing that, if I manage to solve the problem I will report back with the details.

Any help much appreciated!
OOo 3.0.X on Linux-Other + Windows, OpenSolaris 10
Louis Botterill
Posts: 9
Joined: Thu Dec 04, 2008 12:02 pm

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

Post by Louis Botterill »

Hi,

quick update on this. I think it was a combination of things...

firstly, the correct default path for OO3 on Linux (RH etc) seems to be the second one, i.e.

export UNO_PATH=/opt/openoffice.org3/program/

I basically replicated the whole setup I'd tried to do over a terminal on a headless box, on a similar machine with a desktop/display manager so I could see what was going on.

I think what happens is the first time after installing, when soffice is started it launches the registration wizard - and thus hangs.

when I checked on the box where it wasn't working, I am getting a number of soffice processes being launched (so bootstrap is working) but they block when called from the api - I think they must be stuck at this first step - because this is the first time it's ever been launched, it would never be run as a regular user from the desktop.

So, a different problem to solve - but it appears not to be related to this handy jar library - so sorry for any confusion! :)
OOo 3.0.X on Linux-Other + Windows, OpenSolaris 10
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 »

Louis Botterill wrote:I think what happens is the first time after installing, when soffice is started it launches the registration wizard - and thus hangs.
So use the parameter -nofirststartwizard. Take a closer look into the bootstrapconnector JAR file. It contains the example class BootstrapSocketConnectorExample which demonstrates the usage of -nofirststartwizard to get around the problem you described:

Code: Select all

...
    private static void convertWithConnector(String loadUrl, String storeUrl) throws Exception, IllegalArgumentException, IOException, BootstrapException {

        // Create OOo server with additional -nofirststartwizard option
        List oooOptions = OOoServer.getDefaultOOoOptions();
        oooOptions.add("-nofirststartwizard");
        OOoServer oooServer = new OOoServer(OOO_EXEC_FOLDER, oooOptions);

        // Connect to OOo
        BootstrapSocketConnector bootstrapSocketConnector = new BootstrapSocketConnector(oooServer);
        XComponentContext remoteContext = bootstrapSocketConnector.connect();

        // Convert text document to PDF
        convert(loadUrl, storeUrl, remoteContext);

        // Disconnect and terminate OOo server
        bootstrapSocketConnector.disconnect();
    }
...
The crucial line of code for you is oooOptions.add("-nofirststartwizard");
Louis Botterill wrote:so sorry for any confusion!
Thanks for the clarification! :-)
OOo 3.2.0 on Ubuntu 10.04 • OOo 3.2.1 on Windows 7 64-bit and MS Windows XP
Louis Botterill
Posts: 9
Joined: Thu Dec 04, 2008 12:02 pm

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

Post by Louis Botterill »

hol.sten wrote:So use the parameter -nofirststartwizard.
Fantastic, that looks like the exact solution to my exact problem! Thanks ever so much, I won't be able to try this properly on the machine in question until Monday now but I'm confident this was the cause of my problem and the solution you recommend will fix it.

Thanks very much for the help and the example code :)

(Very useful helper library by the way, really glad I found it!)
OOo 3.0.X on Linux-Other + Windows, OpenSolaris 10
Louis Botterill
Posts: 9
Joined: Thu Dec 04, 2008 12:02 pm

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

Post by Louis Botterill »

Hi, just to close the loop on this - I've tried this out on my headless box and it's now all working fine :)

so thanks very much for the assistance!

Just one question. Even after disconnecting, two office processes "soffice" and "soffice.bin" remain running - is this normal / expected?

I notice if I run many reports, I don't get any additional process instances, so I think it's stable (not leaking resources), just wanted to check that once soffice is started, it's meant to remain running (which would make sense to me).
OOo 3.0.X on Linux-Other + Windows, OpenSolaris 10
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 »

Louis Botterill wrote:Even after disconnecting, two office processes "soffice" and "soffice.bin" remain running - is this normal / expected?
Yes, it is normal. And if you don't like it, you can kill OOo. This thread contains a post covering killing OOo.
OOo 3.2.0 on Ubuntu 10.04 • OOo 3.2.1 on Windows 7 64-bit and MS Windows XP
lg_tw
Posts: 1
Joined: Thu Jan 08, 2009 11:15 pm

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

Post by lg_tw »

Hi hol.sten,

thanks for your work! Your utility works really nice when used on Windows Vista and helped me after hours of frustration. However the bootstrap fails on my Mac OS X machine. The office process gets started correctly but the connection attempts fail with "connection refused" and i get stuck in this loop of BootstrapConnector.java.

Code: Select all

 
// wait until office is started
for (int i = 0;; ++i) {
  try {
    xContext = getRemoteContext(xUrlResolver);
    break;
  } catch ( com.sun.star.connection.NoConnectException ex ) {
    // Wait 500 ms, then try to connect again, but do not wait
    // longer than 5 min (= 600 * 500 ms) total:
    if (i == 600) {
      throw new BootstrapException(ex.toString());
    }
    Thread.sleep(500);
  }
}
Only difference in my setup of the two machines is the classpath, which of course respects the different locations of the java_uno.jar, juh.jar and so on. The integration is done using fairly exact your sample code.
I just wanted to ask if you (or someone else reading this) has faced the same problem and can provide some insights or hints.

Thank you in advance, Thomas
OOo 3.0.X on MS Windows Vista + OS X, 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 »

lg_tw wrote:However the bootstrap fails on my Mac OS X machine.
Sorry to read that. I cannot assist you here, because my system isn't running on Mac OS X. But if anyone is delivering such a system to my doorstep, I will look into it ;-)

Thomas, can you tell me, which version of OOo you're using on Windows Vista and which on Mac OS X. Is it the same? Did you try on Mac OS X OOo 3.0.0 or 2.4.x or both versions? If not both, can you try more than just one version of OOo on Mac OS X?
OOo 3.2.0 on Ubuntu 10.04 • OOo 3.2.1 on Windows 7 64-bit and MS Windows XP
dasha311
Posts: 4
Joined: Thu Apr 09, 2009 11:41 am

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

Post by dasha311 »

my program is :
com.sun.star.uno.XComponentContext xContext = null;
try {
String oooExeFolder = "C:/Program Files/OpenOffice.org 3/program";
xContext = BootstrapSocketConnector.bootstrap(oooExeFolder);
if( xContext != null )
System.out.println("Connected to a running office ...");
}
catch( Exception e) {
e.printStackTrace(System.err);
}

i have improted the bootstrapconnector.jar,but i get the follow error
java.lang.UnsupportedClassVersionError: Bad version number in .class file

I am using Java 1.5.0_8 on xp
OOo 3.0.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 »

dasha311 wrote:i have improted the bootstrapconnector.jar,but i get the follow error
java.lang.UnsupportedClassVersionError: Bad version number in .class file

I am using Java 1.5.0_8 on xp
Can you post the stack trace, too? bootstrapconnector.jar was Created-By: 1.5.0_14 (Sun Microsystems Inc.). So it's unlikely that you get the exception from one of the class files of bootstrapconnector.jar whilst using Java 1.5.0_8 on Windows XP.
OOo 3.2.0 on Ubuntu 10.04 • OOo 3.2.1 on Windows 7 64-bit and MS Windows XP
dasha311
Posts: 4
Joined: Thu Apr 09, 2009 11:41 am

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

Post by dasha311 »

this is my programm's exception:
Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number in .class file
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at com.hz.w2p.main(w2p.java:13)
OOo 3.0.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 »

dasha311 wrote:this is my programm's exception:
Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number in .class file
...
at com.hz.w2p.main(w2p.java:13)
And which line of your source code w2p.java is line number 13? That's hard to guess from the program fragment you posted above.

Where are you developing your application? Do you use an IDE? If so, which one?
Do you have multiple JDKs and/or JREs on your computer installed? Which versions are you using for building and for running your application. They cannot be the same.

Googling you'll find a lot of links covering "java.lang.UnsupportedClassVersionError: Bad version number in .class file" errors. Examples:
- http://www.techienuggets.com/Comments?tx=606
- http://lkamal.blogspot.com/2008/04/java ... error.html

My guess is that your problem is not caused by using bootstrapconnector.jar, but from mixing different JDKs on your computer for building and running your application.
OOo 3.2.0 on Ubuntu 10.04 • OOo 3.2.1 on Windows 7 64-bit and MS Windows XP
dasha311
Posts: 4
Joined: Thu Apr 09, 2009 11:41 am

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

Post by dasha311 »

i use the Myeclipse6.0,and the compiler is jdk5.0, this IDE has its own jdk which the version is 1.5.0_11
when i use this jdk, the program has the Exception "java.lang.UnsupportedClassVersionError: Bad version number in .class file"
and i change the jdk version,it aslo has the Exception.

i create a java project .

i see the bootstrapconnector Created-By: 1.5.0_14 (Sun Microsystems Inc.),do i have to use the jdk 1.5.0_14????
OOo 3.0.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 »

dasha311 wrote:i use the Myeclipse6.0,and the compiler is jdk5.0, this IDE has its own jdk which the version is 1.5.0_11
So you're using different JDKs on your computer and in your IDE. That can cause problems.
dasha311 wrote:when i use this jdk, the program has the Exception "java.lang.UnsupportedClassVersionError: Bad version number in .class file"
You already told us. What you still haven't told us, although I already asked explicitly, which line of your source code w2p.java is line number 13? That's hard to guess from the program fragment you posted above.
dasha311 wrote:and i change the jdk version,it aslo has the Exception.
Where ever you changed that. Did you recompile your project after changing the JDK?
dasha311 wrote:i see the bootstrapconnector Created-By: 1.5.0_14 (Sun Microsystems Inc.),do i have to use the jdk 1.5.0_14????
No. And I still think that you're not having problems only with bootstrapconnector.jar. If you want to be sure of that, remove the bootstrapconnector.jar from your projects build and run path, unzip the jar, copy the source code from the jar into your Java project and recompile everything. The bootstrapconnector.jar does not contain only the class files, it contains the complete source code, too. So if your problem is caused by bootstrapconnector.jar, use its source code instead.
OOo 3.2.0 on Ubuntu 10.04 • OOo 3.2.1 on Windows 7 64-bit and MS Windows XP
dasha311
Posts: 4
Joined: Thu Apr 09, 2009 11:41 am

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

Post by dasha311 »

i use the source code , an the programm is running.
thank you very much for your help!!!
OOo 3.0.X on Ms Windows XP
JMysak
Posts: 6
Joined: Tue May 06, 2008 4:09 pm

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

Post by JMysak »

I have been using this solution and it has been working great until I installed OpenOffice 3.0.1 (upgrade from 3.0.0).

After digging into this a bit, I discovered that the soffice executable in 3.0.1 can't be launched from outside of the /program directory.

If I attempt to launch it from outside of the program directory, the following error is displayed to the console (or thrown during runtime, in the case of trying to launch OOo from my program).

>> No Info.plist file in application bundle or no NSPrincipalClass in the Info.plist file, exiting

I posted a question here:
http://user.services.openoffice.org/en/ ... 17&t=17547

but have yet to receive any response, so I am hoping someone on this thread might be able to help find a solution or report a bug to the OOo development team.

Thanks in advance,

John
Selvanayagam
Posts: 5
Joined: Thu Aug 13, 2009 6:12 am

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

Post by Selvanayagam »

Hi,

I am using openoffice 3.0. I have added the bostrapconnector.jar and huh.jar but i get the same error.
OpenOffice 3.0 on Ubuntu 9.04
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 »

Selvanayagam wrote:I am using openoffice 3.0. I have added the bostrapconnector.jar and huh.jar but i get the same error.
Due to some complaints about bootstrapconnector.jar I gave it a try on my computer running Ubuntu 9.04, OOo 3.0.1 (1:3.0.1-9ubuntu3), NetBeans 6.5 (6.5-0ubuntu2.1) and Java 6 from Sun (6-14-0ubuntu1.9.04).

In NetBeans I created a new project and added one simple class file of Java code:

Code: Select all

package oootest;

import com.sun.star.beans.PropertyValue;
import com.sun.star.frame.XComponentLoader;
import com.sun.star.frame.XStorable;
import com.sun.star.lang.XMultiComponentFactory;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;

import ooo.connector.BootstrapSocketConnector;

public class DocumentToPdfWithFilterData {
    public static void main(String[] args) {
        String loadUrl="file:///home/holsten/dev/NetBeansProjects/OOo_3_x_Test/mydoc.odt";
        String storeUrl="file:///home/holsten/dev/NetBeansProjects/OOo_3_x_Test/mydoc.pdf";

        String oooExeFolder = "/usr/lib/openoffice/program/";

        try {
            XComponentContext xContext = BootstrapSocketConnector.bootstrap(oooExeFolder);
            XMultiComponentFactory xMultiComponentFactory = xContext.getServiceManager();
            XComponentLoader xcomponentloader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class,xMultiComponentFactory.createInstanceWithContext("com.sun.star.frame.Desktop", xContext));

            Object objectDocumentToStore = xcomponentloader.loadComponentFromURL(loadUrl, "_blank", 0, new PropertyValue[0]);

            PropertyValue[] conversionProperties = new PropertyValue[2];
            conversionProperties[0] = new PropertyValue();
            conversionProperties[0].Name = "FilterName";
            conversionProperties[0].Value = "writer_pdf_Export";
            conversionProperties[1] = new PropertyValue();
            conversionProperties[1].Name = "Overwrite ";
            conversionProperties[1].Value = new Boolean(true);

            XStorable xstorable = (XStorable) UnoRuntime.queryInterface(XStorable.class,objectDocumentToStore);
            xstorable.storeToURL(storeUrl,conversionProperties);
        }
        catch (java.lang.Exception e) {
            e.printStackTrace();
        }
        finally {
            System.exit(0);
        }
    }
}
Next step was to download bootstrapconnector.jar from this thread and to put it into some folder (I used /home/holsten/dev/NetBeansProjects/lib). Now I had to locate juh.jar, jurt.jar, ridl.jar and unoil.jar. I found them in the folder /usr/share/java/openoffice and copied them into the same folder as bootstrapconnector.jar. Finally I added all five JAR files to the compile-time libraries in the NetBeans project properties.

After setting the main class oootest.DocumentToPdfWithFilterData in the NetBeans project properties I started debugging the class but didn't get any error like "No Info.plist file in application bundle or no NSPrincipalClass in the Info.plist file, exiting" or "java.lang.UnsupportedClassVersionError: Bad version number in .class file". So I'm still puzzled what causes these errors.

All I got was "** (soffice:7120): WARNING **: unable to get gail version number" at the line "XComponentContext xContext = BootstrapSocketConnector.bootstrap(oooExeFolder);". But it is only a warning and caused no problems creating the PDF files. Googling for this warning pointed to some threads describing this error as a font related problem with the OOo version of Ubuntu Jaunty.
OOo 3.2.0 on Ubuntu 10.04 • OOo 3.2.1 on Windows 7 64-bit and MS Windows XP
benzman81
Posts: 2
Joined: Tue Dec 01, 2009 4:05 pm

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

Post by benzman81 »

Hi Hol.sten,

we use the bootstrapconnector.jar in our project and would now like to know under which license the library is made available since we want to distibute it with our LGPL project.
Could you be so kind an include the license in the jar and state it on the first page?

Best regards,
Markus
OpenOffice 3.1 on Windows
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 »

benzman81 wrote:Could you be so kind an include the license in the jar and state it on the first page?
I never intended to use a license. I had the idea, wrote some code (mostly based on source code from OOo's source code, like I mentioned on the first page), put the source and class files in a JAR and made it available here. Is that a problem for you?
OOo 3.2.0 on Ubuntu 10.04 • OOo 3.2.1 on Windows 7 64-bit and MS Windows XP
benzman81
Posts: 2
Joined: Tue Dec 01, 2009 4:05 pm

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

Post by benzman81 »

Well, if I include the jar file in a project without knowing the license for it, then it is a problem to distibute the project since you did not explicitly allow it (i.e. with using LGPL).
OpenOffice 3.1 on Windows
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 »

benzman81 wrote:it is a problem to distibute the project since you did not explicitly allow it (i.e. with using LGPL).
As you can read in the credits section in the first post of this thread, not everything of the source code was written by me. I named all the sources and as far as I know they are free of some sorts. Finally I put all the source files and the compiled class files in a JAR and added it to the post. If you don't want to use the JAR, extract the source code and take what you need and do with it what you want.

I'm not a lawyer and I don't have the slightest clue if or if not it might be possible to put the JAR under any license of some sorts. Sorry. If someday someone can tell me how I can put the JAR under a license, I'll do so. Up till then, do with the source what you want.
OOo 3.2.0 on Ubuntu 10.04 • OOo 3.2.1 on Windows 7 64-bit and MS Windows XP
sasiv
Posts: 1
Joined: Mon Feb 08, 2010 12:49 pm

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

Post by sasiv »

Hai Sir,


Thank you very much for the solution sir.

It solved my problem also


Regards

Sasiv
OpenOffice 3.1 on Windows xp
Post Reply