Re: [Libreoffice] java-application and libreoffice

2011-03-22 Thread Jochen georges

Am 21.03.2011 10:33, schrieb Cedric Bosdonnat:

Hello Jochen,


Can you give me a hint?
Or is there somewhere a step by step howto for dummies?

Could you please use the connection code from JODConvertor to bootstrap
LO? I have extracted it as a jar here:
http://cgit.freedesktop.org/libreoffice/contrib/ooeclipse/tree/java/lib

This is much more reliable and easier to use!


Thank you, well the first steps are the hardest ..
Is there a "Hello World" somewhere?

I found Nice Office Access, that looks good.
Does anybody know that?
Will it be a long-lasting, vivid project?

Thanks a lot!!

Liebe Grüße
Jochen
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


[Libreoffice] java-application and libreoffice

2011-03-18 Thread Jochen georges

Hello Developers,

I hope this is the right place to ask.

I've tried to write a simple Java-Application that writes an odt-file.
I can compile it, but I can't execute it:

Exception in thread "main" java.lang.UnsatisfiedLinkError: 
com.sun.star.lib.connections.pipe.PipeConnection.createJNI(Ljava/lang/String;)I
at 
com.sun.star.lib.connections.pipe.PipeConnection.createJNI(Native Method)
at 
com.sun.star.lib.connections.pipe.PipeConnection.(PipeConnection.java:128)
at 
com.sun.star.lib.connections.pipe.pipeConnector.connect(pipeConnector.java:137)

at com.sun.star.comp.connections.Connector.connect(Connector.java:141)
at 
com.sun.star.comp.urlresolver.UrlResolver$_UrlResolver.resolve(UrlResolver.java:123)

at com.sun.star.comp.helper.Bootstrap.bootstrap(Bootstrap.java:285)
at TestOOAPI.(TestOOAPI.java:20)
at TestOOAPI.main(TestOOAPI.java:15)

Can you give me a hint?
Or is there somewhere a step by step howto for dummies?

Thanks in advance

Beste Grüße
Jochen


TestOOAPI.java

//In Anlehnung an: 
http://openofficejava.blogspot.com/2009/05/openofficeorg-api.html

import com.sun.star.beans.PropertyValue;
import com.sun.star.comp.helper.Bootstrap;
import com.sun.star.comp.helper.BootstrapException;
import com.sun.star.frame.XComponentLoader;
import com.sun.star.lang.XComponent;
import com.sun.star.lang.XMultiComponentFactory;
import com.sun.star.text.XText;
import com.sun.star.text.XTextDocument;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
public class TestOOAPI {
public static void main(String[] args) {
new TestOOAPI();
}
public TestOOAPI(){
try {
// Get the remote office component context
XComponentContext xContext = Bootstrap.bootstrap();
// Get the remote office service manager
XMultiComponentFactory xMCF = xContext.getServiceManager();
try{
// Get the root frame (i.e. desktop) of openoffice 
framework.
Object oDesktop = 
xMCF.createInstanceWithContext("com.sun.star.frame.Desktop", xContext);
// Desktop has 3 interfaces. The XComponentLoader 
interface provides ability to load components.

XComponentLoader xCLoader =
( XComponentLoader ) 
UnoRuntime.queryInterface(XComponentLoader.class, oDesktop);



// Create a document
XComponent document =
   
 xCLoader.loadComponentFromURL("private:factory/swriter", "_blank", 0, 
new PropertyValue[0]);


// Get the textdocument
XTextDocument aTextDocument =
( XTextDocument 
)UnoRuntime.queryInterface(com.sun.star.text.XTextDocument.class, document);


// Get its text
XText xText = aTextDocument.getText();

// Adding text to document
xText.insertString(xText.getEnd(), "My First OpenOffice 
Document", false);


}catch(Exception ex){ex.printStackTrace();}
} catch (BootstrapException e) {e.printStackTrace();}
}
}

compile-run.sh

#!/bin/sh
JAVAC=javac
JAVA=java

export 
CLASSPATH=$CLASSPATH:.:/usr/share/java/openoffice/juh.jar:/usr/share/java/openoffice/jurt.jar:/usr/share/java/openoffice/ridl.jar:/usr/share/java/openoffice/unoil.jar:/usr/lib/openoffice/program/soffice


if [ $1 -eq 0 ]; then
echo "compile"
$JAVAC TestOOAPI.java
elif [ $1 -eq 1 ]; then
echo "run"
#test 1: 
--
export 
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/openoffice/program/

$JAVA TestOOAPI
#test 2: 
--

#$JAVA -Djava.library.path=/usr/lib/openoffice/program/ TestOOAPI
else
echo ""
echo "give me a 0 or 1 please"
fi


diverse pfade

ls /usr/share/java/openoffice/
agenda.jar com commonwizards.jar fax.jar form.jar java_uno.jar 
JREProperties.class js.jar juh.jar juh_src.zip jurt.jar jurt_src.zip 
letter.jar lucene-analyzers-2.3.jar lucene-core-2.3.jar 
LuceneHelpWrapper.jar query.jar report.jar ridl.jar ridl_src.zip 
sandbox.jar saxon9.jar ScriptFramework.jar 
ScriptProviderForBeanShell.jar ScriptProviderForJava.jar 
ScriptProviderForJavaScript.jar table.jar unoil.jar unoloader.jar 
unoloader_src.zip web.jar win XMergeBridge.jar xmerge.ja