Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Java native method problem

1 view
Skip to first unread message

Peter Ordonez

unread,
Jul 3, 1996, 3:00:00 AM7/3/96
to

I'm having a problem getting the sun's native method tutorial working (located at
http://java.sun.com/books/Series/Tutorial/native/stepbystep/index.html). I think
that it's finding the library since if I remove the it I get a different
error. It seems not to be able to find my exported function. I get the following
error from java:

java.lang.UnsatisfiedLinkError: displayHelloWorld
at Main.main(Main.java:20)

If I remove the library, I get:

Exception in thread "main" java.lang.UnsatisfiedLinkError: no hello in
shared library path
at java.lang.Runtime.loadLibrary(Runtime.java:268)
at java.lang.System.loadLibrary(System.java:266)
at HelloWorld.<clinit>(HelloWorld.java:5)
at
java.lang.UnsatisfiedLinkError: displayHelloWorld
at Main.main(Main.java:20)

I get the same problem on both Windows NT and Solaris 2.3. On windows the dll is
called hello.dll, on Solaris it's libhello.so.

Thanks,
-Peter

Kay Priesmeyer

unread,
Jul 4, 1996, 3:00:00 AM7/4/96
to pries...@uke.uni-hamburg.de

Peter Ordonez wrote:
#
# I'm having a problem getting the sun's native method tutorial working (located at
# http://java.sun.com/books/Series/Tutorial/native/stepbystep/index.html). I think
# that it's finding the library since if I remove the it I get a different
# error. It seems not to be able to find my exported function. I get the following
# error from java:
#
# java.lang.UnsatisfiedLinkError: displayHelloWorld
# at Main.main(Main.java:20)
#
# If I remove the library, I get:
#
# Exception in thread "main" java.lang.UnsatisfiedLinkError: no hello in
# shared library path
# at java.lang.Runtime.loadLibrary(Runtime.java:268)
# at java.lang.System.loadLibrary(System.java:266)
# at HelloWorld.<clinit>(HelloWorld.java:5)
# at
# java.lang.UnsatisfiedLinkError: displayHelloWorld
# at Main.main(Main.java:20)
#
# I get the same problem on both Windows NT and Solaris 2.3. On windows the dll is
# called hello.dll, on Solaris it's libhello.so.
#
# Thanks,
# -Peter

I get the very same error on MacOS. If someone figured out how to get this example
working on a MAC, please let me know how.

Kay

Serge Arsenault

unread,
Jul 8, 1996, 3:00:00 AM7/8/96
to

Hi Peter,

> Peter Ordonez <pet...@unisql.com> wrote in article
<31DAF6...@unisql.com>...


> I'm having a problem getting the sun's native method tutorial working
(located at

> http://java.sun.com/books/Series/Tutorial/native/stepbystep/index.html).
I think

> that it's finding the library since if I remove the it I get a different

> error. It seems not to be able to find my exported function. I get the
following

> error from java:
>
> java.lang.UnsatisfiedLinkError: displayHelloWorld
> at Main.main(Main.java:20)
>

> If I remove the library, I get:
>

> Exception in thread "main" java.lang.UnsatisfiedLinkError: no hello in

> shared library path


> at java.lang.Runtime.loadLibrary(Runtime.java:268)
> at java.lang.System.loadLibrary(System.java:266)

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

> at
> java.lang.UnsatisfiedLinkError: displayHelloWorld
> at Main.main(Main.java:20)
>

> I get the same problem on both Windows NT and Solaris 2.3. On windows
the dll is

> called hello.dll, on Solaris it's libhello.so.
>

> Thanks,
> -Peter
>

I have a suggestion for Windows NT :

When you wrote your DLL, did you make a "displayHelloWorld.def" file
exporting the "hello" method? Without it you would have essentially the
same error message since you would load the library and no functions would
be visible outside the DLL.

Hope this helps,

Serge Arsenault,
sar...@volvox.qc.ca


Scott Mitchell

unread,
Jul 8, 1996, 3:00:00 AM7/8/96
to

In article <31DB80...@uke.uni-hamburg.de> Kay Priesmeyer
<pries...@uke.uni-hamburg.de> writes:

I had the same problem under IRIX. The quick but evil solution was to
rebuild the whole shared library -- ie. recompile all the
javah-generated stuff as well as my C code, regardless of whether it
had changed or not. Fortunately the code in question is quite small
so this wasn't too painful.

It's ugly, but it did work. If anyone can explain _why_ it happens I
wouldn't mind hearing from you :)

Scott

--
===========================================================================
Scott Mitchell, CompSci Dept, Queen Mary & Westfield College, London, UK
mailto:sc...@dcs.qmw.ac.uk http://www.dcs.qmw.ac.uk/~scott
finger sc...@ruby.dcs.qmw.ac.uk for PGP public key

0 new messages