Hello Rony: I used your code to successfully build and execute an openoffice UNO client application. (See the attached code).
i executed the jar file from the command line using: java -jar "helloworld.jar" and it launched openoffice writer and wrote the hellow world text into the editor windwo.... I am running ubuntu edgy, openoffice 2.1 , openoffice 2.1 SDK (in /opt/openoffice.org2.1_sdk), jdk 1.5.08 I built the code using Netbeans (using the openoffice wizard, by choosing OpenOffice UNO/Client Application as the project option). On 2/5/07, Rony G. Flatscher <[EMAIL PROTECTED]> wrote:
Hi, ashok _ wrote: > I am running oOo 2.1 on ubuntu....... > > I am running the standard jdk 1.5.08 installation... everything works > fine for me. > > I noticed that i had to explicitly enable Java in oOo after the > installation, by going to tools->options->java and expicitly selecting > a JVM there.... > maybe that is the step you are missing? This seems to be necessary only, if Java is invoked from OpenOffice itself (either via the scripting framework, or because of using a Java UNO component, etc.). If one is using Java from the "outside" of OOo then that version of Java is used to drive OOo. One could set up different vesions of Java and use them to interface with OOo (as a matter of fact I have Java 1.1, 1.2, 1.3, 1.4, 1.5 and 1.6 on my machine, using 1.4 through 1.6 when running against OOo). --- So the question would be for me whether you are able to compile and run the enclosed Java program from the *command* line (not NetBeans, Eclipse etc.) under Ubuntu's OOo? If so, I would be *very* interested in your environment settings! TIA, ---rony --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
/* * helloworld.java * * Created on 05.01.2007 - 09:59:46 * */ package org.openoffice.helloworld; import com.sun.star.uno.XComponentContext; import com.sun.star.comp.helper.Bootstrap; /** * * @author administrator */ public class helloworld { /** Creates a new instance of helloworld */ public helloworld() { } /** * @param args the command line arguments */ public static void main(String[] args) { try { // get the remote office component context XComponentContext xContext = Bootstrap.bootstrap(); com.sun.star.frame.XDesktop xDesktop = null; com.sun.star.lang.XMultiComponentFactory xMCF = null; // (2) get the service manager xMCF = xContext.getServiceManager(); if( xMCF != null ) { System.out.println("Connected to a running office ..."); // (3) start up an instance of office Object oDesktop = xMCF.createInstanceWithContext( "com.sun.star.frame.Desktop", xContext); // (4a) get the XDesktop interface object xDesktop = (com.sun.star.frame.XDesktop) com.sun.star.uno.UnoRuntime.queryInterface( com.sun.star.frame.XDesktop.class, oDesktop); // (4b) get the desktop's component loader interface object com.sun.star.frame.XComponentLoader xComponentLoader = (com.sun.star.frame.XComponentLoader) com.sun.star.uno.UnoRuntime.queryInterface( com.sun.star.frame.XComponentLoader.class, xDesktop); // create an empty text ("swriter") document com.sun.star.beans.PropertyValue xEmptyArgs[] = // empty property array new com.sun.star.beans.PropertyValue[0]; // (5) create an empty word processor ("swriter") component (document) com.sun.star.lang.XComponent xComponent = xComponentLoader.loadComponentFromURL( "private:factory/swriter","_blank", 0, xEmptyArgs); // (6) get Text interface object and set a text com.sun.star.text.XTextDocument xTextDocument = (com.sun.star.text.XTextDocument) com.sun.star.uno.UnoRuntime.queryInterface( com.sun.star.text.XTextDocument.class, xComponent); com.sun.star.text.XText xText = xTextDocument.getText(); // ((com.sun.star.text.XTextRange) xText).setString("Java was here!\r---rgf"); xText.setString("Java was here!\r---rgf"); } } catch (java.lang.Exception e){ e.printStackTrace(); } System.exit( 0 ); } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]