java.lang.UnsatisfiedLinkError

I am using a very simple "Hello World" JNI example. It can be found googling I'm sure. Really nothing to it. However when I compile, I get that error.

wk88:/workspace/newJNI/ jv -Djava.library.path=. HelloWorld Exception in thread "main" java.lang.UnsatisfiedLinkError: /workspace/newJNI/libHelloWorld.so: /workspace/newJNI/libHelloWorld.so: cannot open shared object file: No such file or directory

at java.lang.ClassLoader$NativeLibrary.load(Native Method)

at java.lang.ClassLoader.loadLibrary0(Unknown Source)

at java.lang.ClassLoader.loadLibrary(Unknown Source)

at java.lang.Runtime.loadLibrary0(Unknown Source)

at java.lang.System.loadLibrary(Unknown Source)

at HelloWorld.<clinit>(HelloWorld.java:7)

I am running on a CentOS system with an AMD X86_64 bit arch.

However, I'm using gcc to compile my code. Can't get the powers that be to authorize the use of JDK yet...

I'm thinking it's compiling the code with the x86_64 bit arch, yet we only have JRE 1.6.0_01 for 32 bit installed. Therefore it cannot properly link the shared object to the java program.

Any suggestions?

Thanks

[1175 byte] By [jjhusa01a] at [2007-11-27 2:53:31]
# 1
>cannot open shared object That certainly suggests something is wrong with the library itself.> Any suggestions?The documentation for the compiler would be a good place to start.
jschella at 2007-7-12 3:28:33 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 2

I found a co-worker with one of the older 32 bit Unix systems and was able to ssh into his machine. I compiled the code and it worked.

It has to do with my compiler. Now to find the option to compile as 32 bit. I have tried the options as -m32 and such, but doesn't seem to recognize it. I'm starting to think whoever compiled gcc may have done something wrong.

jjhusa01a at 2007-7-12 3:28:33 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 3

Why dont you try borland c++ compiler..it works better in handling your situation..

Before that did you create a dll and embedd the manifest in the dll.

If you have created the dll using visual c++ , then download 'dependency walker' a free tool from microsoft and check whether your dll is intact.. When you open in the dll in the dependency walker it will suggest you if something is missing.

IF it is it fine, make sure your dll is in the current directory before using the loadlibrary in java and it has to be wrapped in static so that it will be loaded when class is loaded.

You get this issue due to path problems or if the parameters are not matching as in the DLL as for your java callign method.

Sujiea at 2007-7-12 3:28:33 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 4
> Why dont you try borland c++ compiler..it works> better in handling your situation..> > Before that did you create a dll and embedd the> manifest in the dll.> For starters because the question has nothing to do with windows.
jschella at 2007-7-12 3:28:33 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 5
I am in a very controlled environment. I really am stuck using what is given to me. As jschell pointed out, I am on linux platform and not windows.
jjhusa01a at 2007-7-12 3:28:33 > top of Java-index,Java HotSpot Virtual Machine,Specifications...