View previous topic :: View next topic |
Author |
Message |
Tekikke Blue Pill
Joined: May 02, 2007 Posts: 4
|
Posted: Wed May 02, 2007 2:34 am Post subject: Connect to neo office with Eclipse Java |
|
Hi,
i need to connect to neo office and run a macro there.
but when i start with the following code, i always get in the Catch, and the 'connected to a running office' doesn't appear.
Does someone has an idea why this doesn't work correct?
Code: |
try {
com.sun.star.uno.XComponentContext xContext = null;
xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
xMCF = xContext.getServiceManager();
if( xMCF != null ) {
System.out.println("Connected to a running office ...");
Object oDesktop = xMCF.createInstanceWithContext("com.sun.star.frame.Desktop", xContext);
xDesktop = (com.sun.star.frame.XDesktop)
com.sun.star.uno.UnoRuntime.queryInterface(com.sun.star.frame.XDesktop.class, oDesktop);
com.sun.star.frame.XComponentLoader xComponentLoader =(com.sun.star.frame.XComponentLoader)
com.sun.star.uno.UnoRuntime.queryInterface(com.sun.star.frame.XComponentLoader.class, xDesktop);
com.sun.star.beans.PropertyValue xEmptyArgs[] = // empty property array
new com.sun.star.beans.PropertyValue[0];
com.sun.star.lang.XComponent xComponent = // text document
xComponentLoader.loadComponentFromURL ( "private:factory/swriter","_blank", 0, xEmptyArgs);
executecommand(xComponent,macroModule, temploc );
xComponent.dispose();
}
else{
System.out.println("Not able to create desktop object.");
}
}
catch( Exception e) {
..............
|
i get the following error:
com.sun.star.comp.helper.BootstrapException: no office executable found!
i think its because i've copied the classes to a different location. because with eclipse i can't import clases who are part of a package. and NeoOffice is one big package.. |
|
Back to top |
|
|
pluby The Architect
Joined: Jun 16, 2003 Posts: 11949
|
Posted: Wed May 02, 2007 8:39 am Post subject: Re: Connect to neo office with Eclipse Java |
|
Tekikke wrote: | i think its because i've copied the classes to a different location. because with eclipse i can't import clases who are part of a package. and NeoOffice is one big package.. |
I assume that you are using the OpenOffice.org SDK, right? If so, they have detailed instructions on how to configure and start OpenOffice.org before you execute your code. The OOo SDK classes work by making a socket connection to a running instance of OpenOffice.org or NeoOffice so you need to specify the host and port of the running intance somewhere in your code.
It has been a year or two since I last used the OOo SDK so I can't tell you what exactly is needed. For that, you will have to sift through the OOo SDK documentation.
Patrick |
|
Back to top |
|
|
Tekikke Blue Pill
Joined: May 02, 2007 Posts: 4
|
Posted: Thu May 03, 2007 12:20 am Post subject: |
|
i use already the jar files from NeoOffice in eclipse.
If i do the same on a linux or windows system, 'openoffice' starts and execute the macro. But there should be something different on mac.
Does someone has any idea why NeoOffice doesn't start with this code?
grtzz |
|
Back to top |
|
|
pluby The Architect
Joined: Jun 16, 2003 Posts: 11949
|
Posted: Thu May 03, 2007 8:47 am Post subject: |
|
Copying the jar files from NeoOffice into Eclipse is not going to make it obvious to the OpenOffice.org SDK code (yes, that is what you are using) where NeoOffice is installed.
Again, the OpenOffice.org SDK code tries to launch NeoOffice or OpenOffice.org. Unless you following the OpenOffice.org SDK directions for specifying where it is installed, the SDK code will fail.
The OpenOffice.org SDK documentation is here:
http://udk.openoffice.org/common/man/spec/transparentofficecomponents.html
There are several path properties that the OpenOffice.org SDK says are required in that page. Read the page and use them.
Patrick |
|
Back to top |
|
|
Tekikke Blue Pill
Joined: May 02, 2007 Posts: 4
|
Posted: Mon May 07, 2007 11:37 pm Post subject: |
|
i've imported the neoOffice, jar files again and i have another error now.
Code: |
Exception in thread "main" java.lang.UnsatisfiedLinkError: createJNI
at com.sun.star.lib.connections.pipe.PipeConnection.createJNI(Native Method)
at com.sun.star.lib.connections.pipe.PipeConnection.<init>(PipeConnection.java:137)
at com.sun.star.lib.connections.pipe.pipeConnector.connect(pipeConnector.java:145)
at com.sun.star.comp.connections.Connector.connect(Connector.java:146)
at com.sun.star.comp.urlresolver.UrlResolver$_UrlResolver.resolve(UrlResolver.java:133)
at com.sun.star.comp.helper.Bootstrap.bootstrap(Bootstrap.java:292)
|
Does someone has an idea what this error means, and what i can do to repair this error? |
|
Back to top |
|
|
Tekikke Blue Pill
Joined: May 02, 2007 Posts: 4
|
Posted: Thu May 10, 2007 12:19 am Post subject: |
|
thx,
i've read that page a hundred time but i can't find anything i don't do.
I use the code to connect like its on that page.
But maybe it has something to see with the environment variables, i've searched the internet and there's something to find about. But always on un*x systems not on mac os. And the variables i've found for linux are not working on my mac.
Maybe someone knows something more about this?
grtzz |
|
Back to top |
|
|
|