Freebsd4.10 can not load library

testjni.java

public class testjni

{

public naive void hello();

static{System.loadLIbrary("testjni");}

pulic static void main(String[] args)

{new testjni().hello();}

}

--

ls

==================

testjni.class testjni.java testjni.c

testjni.h testjni.so

=======================

java testjni

Exception in thread main....

no testjni in java.library.path

=====================

java -Djava.library.path=. testjni

Exception in thread main....

no testjni in java.library.path

=======================

java -Djava.library.path=testjni.so testjni

Exception in thread main....

no testjni in java.library.path

why?

freebsd 4.10.

jdk1.4.2

[791 byte] By [dinghaijianga] at [2007-10-1 23:28:32]
# 1

cp testjni.so libtestjni.so

java testjni

Exception in thread main....

no testjni in java.library.path

=====================

cp testjni.so /jdk1.4.2/bin

java testjni

Exception in thread main....

no testjni in java.library.path

=====================

cp testjni.so /jdk1.4.2/jre/bin

java testjni

Exception in thread main....

no testjni in java.library.path

=====================

cp testjni.so /usr/lib

java testjni

Exception in thread main....

no testjni in java.library.path

=======================

how to solve it?

dinghaijianga at 2007-7-15 14:11:04 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 2
1) I would highly recommend not running as root, which I presume you are as you are copying stuff into /usr/lib2) try java -java.library.path=<The DIRECTORY where your library is, not the library itself>
IanSchneidera at 2007-7-15 14:11:04 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 3
I apologize for 2, I read too fast and missed that you tried this...Use the code tags so things are more readable.When you use System.loadLibrary("foo"), the jvm will search the path for libfoo.so, so make the appropriate change when you compile your library.
IanSchneidera at 2007-7-15 14:11:04 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 4
can you speak more about it?thanks.I can not run it correctly because of the library, and i change a common user not root to run it . no use.problem still exists.
dinghaijianga at 2007-7-15 14:11:04 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 5
can you speak more about it?thanks.I can not run it correctly because of the library, and i change a common user not root to run it . no use.problem still exists.
dinghaijianga at 2007-7-15 14:11:04 > top of Java-index,Java HotSpot Virtual Machine,Specifications...