Hi guys,
In the past I have been playing around with the OOo SDK trying to bootstrap OOo
without knowing in advance what the path to the OOo program directory is. I have
written a few blogs about OOo and one of the questions I frequently get is how
to do just that. People are very much interested in creating applications that
do OOo stuff either from Java Web Start or through another mechanism.
Masically, the problem is quite simple to explain. Suppose we have a
configuration file, e.g. <home>/.oooprops, that contains one or more lines
stating the location of OOo, e.g.
OOO_HOME=/usr/lib/openoffice
In this directory, the program dir should be. The default bootstrap method
cannot be used since this needs to have the path above (or actually
$OOO_HOME/program) in java.library.path. On Windows, this can be done by adding
$OOO_HOME/program to the PATH variable, on Linux by adding $OOO_HOME/program to
the LD_LIBRARY_PATH variable. What if our users, for whatever reason, are not
capable of adding $OOO_HOME/program to either one of those variables?
In order to sove that issue I dug into the Bootstrap javadoc and browsed a lot
via Google, OOo forums etc and finally found out that there is a SYSBINDIR
variable that can be set. I wrote this next piece of Java code
private void myBootstrap() {
System.out.println("java.class.path = \"" +
System.getProperty("java.class.path") + "\"");
System.out.println("java.library.path = \"" +
System.getProperty("java.library.path") + "\"");
try {
String sofficepath = "file:///usr/lib/openoffice/program";
String unoini = sofficepath + "/unorc";
Hashtable<String, String> bootProperties = new Hashtable<String,
String>();
bootProperties.put("SYSBINDIR", sofficepath);
bootProperties.put("ORIGIN", sofficepath);
XComponentContext xContext =
Bootstrap.defaultBootstrap_InitialComponentContext(null, bootProperties);
} catch (Exception ex) {
Logger.getLogger(MyOOoBootstrapper.class.getName()).log(Level.SEVERE, null, ex);
}
}
Whenever I execute the above method I get this error message:
java.class.path =
"/usr/lib/openoffice/program/classes/juh.jar:/usr/lib/openoffice/program/classes/jurt.jar:/usr/lib/openoffice/program/classes/ridl.jar:/usr/lib/openoffice/program/classes/unoil.jar:build/classes/"
java.library.path =
"/usr/lib/jvm/java-6-sun-1.6.0.00/jre/lib/i386/client:/usr/lib/jvm/java-6-sun-1.6.0.00/jre/lib/i386:/usr/lib/jvm/java-6-sun-1.6.0.00/jre/../lib/i386:/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib::/usr/java/packages/lib/i386:/lib:/usr/lib"
Exception in thread "main" java.lang.UnsatisfiedLinkError: no juh in
java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1682)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1030)
at
com.sun.star.comp.helper.Bootstrap.defaultBootstrap_InitialComponentContext(Bootstrap.java:213)
at
nl.reeven.van.test.ooo.MyOOoBootstrapper.myBootstrap(MyOOoBootstrapper.java:34)
at nl.reeven.van.test.ooo.MyOOoBootstrapper.main(MyOOoBootstrapper.java:22)
Just for fun, I did
export LD_LIBRARY_PATH=/usr/lib/openoffice/program
and now I get this error
java.class.path =
"/usr/lib/openoffice/program/classes/juh.jar:/usr/lib/openoffice/program/classes/jurt.jar:/usr/lib/openoffice/program/classes/ridl.jar:/usr/lib/openoffice/program/classes/unoil.jar:build/classes/"
java.library.path =
"/usr/lib/jvm/java-6-sun-1.6.0.00/jre/lib/i386/client:/usr/lib/jvm/java-6-sun-1.6.0.00/jre/lib/i386:/usr/lib/jvm/java-6-sun-1.6.0.00/jre/../lib/i386:/usr/lib/openoffice/program:/usr/java/packages/lib/i386:/lib:/usr/lib"
Feb 7, 2008 11:53:57 AM nl.reeven.van.test.ooo.MyOOoBootstrapper myBootstrap
SEVERE: null
com.sun.star.uno.RuntimeException: cannot get mapping C++ <-> Java!
at com.sun.star.comp.helper.Bootstrap.cppuhelper_bootstrap(Native Method)
at
com.sun.star.comp.helper.Bootstrap.defaultBootstrap_InitialComponentContext(Bootstrap.java:218)
at
nl.reeven.van.test.ooo.MyOOoBootstrapper.myBootstrap(MyOOoBootstrapper.java:34)
at nl.reeven.van.test.ooo.MyOOoBootstrapper.main(MyOOoBootstrapper.java:22)
I am not able to find anything about that error message via Google or OOo
forums. Would anyone have a clue what this error means and how to solve it? By
the way, I am using OOo 2.3.1 on Debian Linux.
Thanks, Wouter van Reeven
--
People: "If she weighs the same as a Duck, she's made of wood!"
Sir Bedevere: "And therefore...?"
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]