Getting started with UNO and Java with Open/LibreOffice
Asked Answered
M

5

7

I just started to develop a Java project using LibreOffice's 4.0.1 UNO SDK, aaaand... I'm pretty much stuck right at the beginning. I think the same can be applied if I used OpenOffice.org instead of LibreOffice, so any help is appreciated.

I'm using Eclipse Juno 4.2 and I created a "Hello World"-like project. I added the /program directory to the classpath (added as an external class folder), and right at the beginning this line of code

XComponentContext ctx = Bootstrap.bootstrap();

throws an UnsatisfiedLinkError exception with the following stack trace:

Exception in thread "main" java.lang.UnsatisfiedLinkError: no jpipe in java.library.path
    at java.lang.ClassLoader.loadLibrary(Unknown Source)
    at java.lang.Runtime.loadLibrary0(Unknown Source)
    at java.lang.System.loadLibrary(Unknown Source)
    at com.sun.star.lib.util.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:50)
    at com.sun.star.lib.connections.pipe.PipeConnection.<clinit>(PipeConnection.java:48)
    at com.sun.star.lib.connections.pipe.pipeConnector.connect(pipeConnector.java:110)
    at com.sun.star.comp.connections.Connector.connect(Connector.java:114)
    at com.sun.star.comp.urlresolver.UrlResolver$_UrlResolver.resolve(UrlResolver.java:108)
    at com.sun.star.comp.helper.Bootstrap.bootstrap(Bootstrap.java:301)
    at xx.test.unotest.UnoTest.main(UnoTest.java:16)

There's even a try/catch surrounding the instruction but it's not triggered.

I can't find decent documentation about getting started with UNO, so I don't know what went wrong. The SDK is installed and the environment variables are configured.

Am I missing something?

Edit: I'using Windows 7 64 bit. Maybe this has something to do with the problem.

Manservant answered 19/3, 2013 at 15:2 Comment(6)
Try out the following connection: -accept=socket,host=localhost,port=8100;urp;StarOffice.ServiceManager From oooforum.org/forum/viewtopic.phtml?t=27578Fieldfare
@zachlatta Sadly, I get the same result.Manservant
Are your Java environment variables set correctly?Fieldfare
@zachlatta I'd say yes, but I don't get where I can look to check if something is wrong.Manservant
Reading from that same forum thread, it looks like they had success with -accept=socket,host=localhost,port=8100;urp;. Let me know if that works.Fieldfare
@zachlatta Yeah, I tried that too, but I get the same result.Manservant
M
8

Well, that's it, the library jpipe.dll wasn't found in the directories listed in the PATH environment variable. I had to add the path LibreOffice 4.0/URE/bin to that.

Adding the path to the java.library.path wouldn't work.

So, after a very annoying SDK installation, which required a GNU make tool that I won't use and forced me to install MinGW, and a crappy zip tool that couldn't simply be found since the mirrors from info-zip.org (the source given by api.libreoffice.org) are all down, I still had these stupid and undocumented problems.

Once this was solved, the 64 bit thing was actually a problem, since jpipe.dll is a 32 bit only library and couldn't be loaded, so I had to switch to a 32 bit JDK/JRE in order to make it work.

Man. I can do without some interface user-friendliness, but this is just making the life of a developer unnecessarily hard!

This is why open source software sometimes sucks.

Manservant answered 21/3, 2013 at 10:54 Comment(3)
add /usr/lib/ure/lib to classpath (for libjpipe.so) on linuxCaliper
Tested on: Linux Mint 18.3 Sylvia. Adding this parameter solves problem: -Djava.library.path="/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib:/usr/lib/libreoffice/program/"Jerad
Thank you guys - workling now on linux mint 20.3.Pohl
P
2

If you are using 32 bit of libreoffice then the u need to switch 32 but of jdk to work.Otherwise download the latest version of libreoffice of 64bit

Pesky answered 23/7, 2015 at 8:42 Comment(0)
G
1

In MacOS the libpipe library is located at /Applications/LibreOffice.app/Contents/Frameworks/libjpipe.jnilib. So you need to run Java like this.

java -cp \
  '.:/Applications/LibreOffice.app/Contents/MacOS/:any-other-jars.jar' \
  -Djava.library.path=/Applications/LibreOffice.app/Contents/Frameworks \
   com.example.YourAppClass
Gaia answered 20/5, 2020 at 17:29 Comment(0)
D
0

Try to link the libjpipe.so library to lib directory inside of your project:

ln -s /usr/lib/libreoffice/program/libjpipe.so your_project/lib/
Detestable answered 21/11, 2019 at 10:46 Comment(0)
C
0

For Ubuntu 18.04 I was able to solve the issue by adding libjpipe.so to this location file:///usr/lib/jni/libjpipe.so

You can get this file from /usr/lib/libreoffice/program/libjpipe.so if you have installed libre office.

This should solve the issue.

Chlorophyll answered 11/5, 2020 at 6:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.