Need help with Unsatisfied Link Error

T

Ten Blade

I am trying to make a start with UNO, the Open Office Org technology for
writing OOO documents via Java programs. Unfortunately, I'm having
trouble with my very first program and not finding any help on the OOO
forums.

Here's the stacktrace that I get when I try to run the program using the
Ant script that they supply:

run:
[java] Exception in thread "main" java.lang.UnsatisfiedLinkError: no
unowinreg in java.library.path
[java] at java.lang.ClassLoader.loadLibrary(Unknown Source)
[java] at java.lang.Runtime.loadLibrary0(Unknown Source)
[java] at java.lang.System.loadLibrary(Unknown Source)
[java] at com.sun.star.lib.loader.WinRegKey.<clinit>
(WinRegKey.java:90)
[java] at
com.sun.star.lib.loader.InstallationFinder.getPathFromWindowsRegistry
(InstallationFinder.java:201)
[java] at com.sun.star.lib.loader.InstallationFinder.getPath
(InstallationFinder.java:109)
[java] at com.sun.star.lib.loader.Loader.getCustomLoader
(Loader.java:174)
[java] at com.sun.star.lib.loader.Loader.main(Loader.java:134)

BUILD FAILED
C:\eclipse\workspace\FirstUnoContact\build.xml:62: Java returned: 1


I have no idea what unowinreg is or does but I did manage to find it - I
think. There is a unowinreg.dll in a cab file called openofficeorg1.cab.
That cab file is in the OOO 3.3 SDK. I'm guessing that that's what my
program needs to find to run successfully.

To start with, I don't know if a Java program can use a dll that is
sitting in a cab file. I've never come across that situation before. Can
anyone tell me if that is even theoretically possible? Perhaps there is
another unowinreg somewhere else and this one is a red herring?

If it _is_ possible, can anyone tell me how to make that dll visible to
my program at run time? I've tried adding the cab file to the Eclipse
project in the Properties/Build Path/Libraries window but the 'run' step
still fails on the same error. I've also tried adding -Djava.library.path
VM argument to the Ant script that contained the 'run' target but that
failed too. I got the exact same error in both situations.

I'm running on Windows XP SP2 using Eclipse 3.7 (Indigo).
 
R

Rhino

Roedy Green said:


Something really critical for me to know here is whether it is indeed
possible for a Java program to link with a DLL in a cab file. I'm not even
positive I have the right file so I'd like to be sure that linking to the
DLL is possible in the first place, particularly when it is within a cab
file. Perhaps I need to copy it from the cab file into a directory? Or can
Java 'see' DLLs in a cab file the same way it can read class files in a jar?

I'm running Windows XP SP2.
 
R

RedGrittyBrick

Something really critical for me to know here is whether it is indeed
possible for a Java program to link with a DLL in a cab file.

As I understand it, Windows cabinet files (.cab) are intended for use by
an application installer, not by another application. The installer
would normally extract DLLs from a cabinet file and install them into
the correct place.

For this reason I'd be surprised if JNI had some general way of knowing
which cab files might contain a needed DLL.

I'm not
even positive I have the right file so I'd like to be sure that linking
to the DLL is possible in the first place, particularly when it is
within a cab file. Perhaps I need to copy it from the cab file into a
directory? Or can Java 'see' DLLs in a cab file the same way it can read
class files in a jar?

"Java Uno is the implementation of Uno (Runtime, Core Components,
utilities) for Java. Java Uno interoperates with Binary Uno via the JNI
- Binary Uno bridge"

Are you certain you have properly 0installed Binary UNO?
 
T

Ten Blade

As I understand it, Windows cabinet files (.cab) are intended for use
by an application installer, not by another application. The installer
would normally extract DLLs from a cabinet file and install them into
the correct place.
Sounds reasonable. I had a vague sense that user programs don't access
files from cab files from the first but didn't know enough to be
sure....

For this reason I'd be surprised if JNI had some general way of
knowing which cab files might contain a needed DLL.

Sounds reasonable.
"Java Uno is the implementation of Uno (Runtime, Core Components,
utilities) for Java. Java Uno interoperates with Binary Uno via the
JNI - Binary Uno bridge"

Are you certain you have properly 0installed Binary UNO?

Excellent question but I'm not sure how to answer it. I know virtually
nothing about UNO and how it works, just that it was a technique I saw
recommended to meet my needs of creating documents that could be read by
Word.

I can't find anything in the way of documentation telling you exactly
how the UNO SDK is to be installed but, on the chance that I chose an
inappropriate option during the installation the first time, I
uninstalled the SDK completely and then reinstalled it. There was really
just one option during the install, namely where it was supposed to be
installed relative to OpenOfficeOrg itself. I simply took the default
value this time - as I think I did the first time too - and let it
reinstall. I had no information on a better place to install it so that
seems likely to be the right place.

Once I'd reinstalled the SDK, I noticed that there was a unowinreg.dll
in one of the folders in the SDK but this one was NOT in a cab file.
Eureka, I thought! I noted the full path to unowinreg.dll but did
nothing else about it for the moment.

I tried preparing and running the program again but it failed on the
same error; no surprise. I tried adding the path to the unowinreg.dll to
the java.library.path but seem to have screwed it up because I couldn't
get it to see the dll for love or money.

Finally, I googled some more and saw the suggestion that as long as
unowinreg.dll was in one of the folders specified in the
java.library.path - it didn't matter which one - I should be good to go.
I put it in an eclipse folder that was in the path, stopped and started
Eclipse, but still got the error message. Then I deleted it from the
eclipse folder and put a copy of unowinreg.dll in c:\windows\system32,
rebooted the computer and NOW I can run the program successfully!
Problem solved!!

Thanks to you and Roedy for getting me going in the right direction!!

Now I can finally start to learn about UNO!
 
R

Roedy Green

particularly when it is within a cab
file

Even if you could, it would slow down DLL load considerably since they
are compressed. Look for DLLs on the path, and the library path you
can determine with system properties.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top