Geertjan's Blog

  • July 25, 2006

OpenOffice.org via Web Start on Windows

Geertjan Wielenga
Product Manager
Evan Summers describes how to set up Java Web Start in NetBeans IDE 5.0 and I've been trying to get it to work for an application that integrates OpenOffice.org. The application itself is very simple (since this is just an experiment):

So, you specify the location of your OpenOffice.org executable. (Also successfully tested for Star Office 8 and Star Office 7). A default value (valid for my environment but not necessarily for yours) is filled in for you. Then you click one of the buttons and the related OpenOffice.org application opens. In the case of Writer and Calc, a "Hello World" text is added to the document, while for Draw, the application simply opens without doing anything extra.

So, how to make this application available via Web Start? First, I went through Evan's very useful tutorial in his blog (here). For the signing of the JAR files, I used Ant scripts (as described here). Then I ended up with a series of signed OpenOffice.org JARs (juh.jar, jurt.jar, ridl.jar and unoil.jar), as well as swing-layout-1.0.jar and the JAR providing the user interface (shown above) and the interaction with OpenOffice.org. Thanks (a lot) to Wouter van Reeven (the OpenOffice.org expert who I met last month at J-Spring in Holland), who handled the OpenOffice.org side of the story, including the implementation of a local bootstrap method, replacing the remote connection method that I had been using until then.

So, all the JARs were signed and ready for action. I couldn't upload them into my blog, because there were too many and they were too large. So I uploaded them onto www.geocities.com. Not perfect, but it does the job. Thanks to NetBeans, I had a great editor for putting together the JNLP file:

I uploaded the JNLP file into this blog. It's nice that I'm able to put my JNLP file in one place while the JARs are in another (very same principle as the NetBeans autoupdate descriptors). But then the fun began! These are the errors that first draw your attention to there being something wrong:

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.(PipeConnection.java:156)

I got this error when clicking any of the buttons in the application. It turned out, after a lot of investigation (by Wouter and me) that we needed to provide native libraries, which (as one would assume, given that the libraries are "native") are different per platform. I worked out how to do it for Windows. Just wrap the SDK's unowinreg.dll file in a JAR file and then sign it (using the approach described here). Then I uploaded the signed native library to the same place on www.geocities.com, after adding a reference to it in the "Library" section of the editor, as you can see in the screenshot above. You need to specify an operating system, so I put "Windows" there.

However, neither Wouter nor I know which parts of the OpenOffice.org SDK Linux (and other platforms) distribution need to be provided in a JAR file. That's why this currently only works under Windows. If someone can tell me which native parts of the OpenOffice.org SDK Linux distribution needs to be put in a signed JAR file, I can include support for those other platforms.

But the UnsatisfiedLinkError problem persisted! And that's when I worked out that the folder that contains the executable needs to be on the java.library.path. And, on Windows you can add the folder to the Java library path by putting it on the classpath. That's what I did. Next, you make sure that the Java Console will be shown when you're in Web Start. (Go to Control Panel and click Java, then go to the Advanced panel and click the button for showing the Java Console.) When you click on the button below (remember, currently only functioning for Windows) and you get to the application shown at the start of this blog entry, you will see a Java Console with this content:

The last line in the above screenshot comes from code that I added to the JAR that provides all the functionality and integration with OpenOffice.org. It just prints out the current content of java.library.path. If you do not find the full path to the folder containing the OpenOffice.org (or Star Office) executable, you will get the UnsatisfiedLinkError error when you click any of the buttons in the application. In that case, add the folder to the classpath (in the Environment Variables section for your system).

Now, bearing all of this in mind, click this button:


And what's the point of this application? Well, imagine an application (possibly a Swing application built on the NetBeans Platform) distributed via Web Start... there's a good chance that it might need to integrate with OpenOffice.org, for spreadsheets or diagrams or whatever. The application in this demonstration is very simple, but it could be very extensive. And now it is clear that it can be distributed via Web Start. And because the native libraries are wrapped with the application, you don't need to have the OpenOffice.org SDK installed on your system. Not bad, I think.

Again, if there's anybody out there who knows which native libraries are required by other platforms for integration with OpenOffice.org... please let me know! Also, if you're on Windows, please click the button above and give the demo a try.

Join the discussion

Comments ( 12 )
  • Wouter van Reeven Tuesday, July 25, 2006
    Thanks a lot for your recent hints via email. On Linux, doing this
    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/openoffice/program:
    and then
    javaws http://blogs.sun.com/roller/resources/geertjan/JavaApplication1.jnlp
    made OpenOffice.org start and display "Hello World"!
    Greets, Wouter
  • Geertjan Tuesday, July 25, 2006
    Wow. That must mean that native libraries are not needed. At least under Linux. Weird. I'll test some more under Windows. But, from what I've read, setting LD_LIBRARY_PATH is not the best solution, although there don't seem to be many other solutions...
  • Alan Burlison Tuesday, July 25, 2006
    I did a detailed writeup on how to use Netbeans and JNLP to build and deploy apps that use Win32 DLLs - check out http://blogs.sun.com/roller/page/alanbur?entry=netbeans_jni_webstart_and_apache

    You might also like to check out the pack200 stuff - it makes a \*huge\* difference to the size of JAR files (not to ones that contain DLLs though).

  • Geertjan Thursday, July 27, 2006
    Hi Alan, you have some interesting blog entries on web start! Thanks -- I'll be referring to them in the future.
  • Geertjan Thursday, July 27, 2006
    I have just updated the JNLP application. Now you don't need to set the path or anything at all. Just click the "Launch" button and the application will work out of the box.
  • Pieter-jan Malfait Tuesday, September 12, 2006
    Hi Geertjan,
    In your last post you mention that you modified your JNLP application so the path doesn't needs to be set on the client machine anymore. I assume you set the path automatically from java, or something like that. How did you do that? Because that is exactly what i need for my current application.
  • Wouter van Reeven Wednesday, September 13, 2006
    Hi Pieter-Jan,
    Since you also emailed me I have responded to you via private mail. The trick is to modify the Bootstrap class and introduce some dirty tricks. I do NOT recommend that you use this class for the reasons I put in the mail as well.
    Greets, Wouter
  • Carlos Peña Wednesday, September 27, 2006
    Hi Wouter:
    Please post the answer to Geertjan about modified JNLP application. Greets and thanks!
  • Mark Olthof Tuesday, October 3, 2006
    Hi all, I finally figured it all out. Follow the procedure from http://codesnippets.services.openoffice.org/Office/Office.BootstrapOpenOffice.snip which is used for bootstrapping OpenOffice. This procedure will fail for Java Web Start because JWS uses it's own classloader (JNLPClassLoader). So we have to rewrite Loader.java to use the JNLPClassLoader instead of the CustomClassLoader. That's all! -> http://wwwhome.cs.utwente.nl/~olthofm/pub/UNO_jws/com/sun/star/lib/loader/Loader.java
    Mvg, Mark
  • srinivas reddy Tuesday, July 3, 2007
    hi iam getting this error iam running the openoffice api using java with tomcat please help me
    java.lang.UnsatisfiedLinkError: createJNI

    com.sun.star.lib.connections.pipe.PipeConnection.createJNI(Native Method)


  • Rene van Oevelen Friday, August 22, 2008

    Hello Geertjan,

    I'm new to NetBeans and Java, so I have to read and learn a lot (my head hurts!). I'm amazed to find out how many experts are Dutch! Great!

    I read the above with much interest, but you lost me when explaining using NetBeans for editing a jnlp file. I can not find this option. I use NetBeans 6.1 in which the Help function does not work because of a bug, so the Help does not help. Can you help and explain how I do this?

    Met vriendelijke groet, René

  • Gabor Fericsan Monday, November 30, 2009

    Hi, i see a great jnlp multiview editor here, but the new netbeans releases (6.5/6.7) i can not find this. Could you help me? Thanks, Gabor

Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.