dcsimg
Unsatisfied Link Error
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Al_Lelopath
Posted On:   Tuesday, January 4, 2005 03:06 PM

I am trying to do a JNI example but getting an UnsatisfiedLinkError. I am following the example at: http://java.sun.com/developer/onlineTraining/Programming/JDCBook/jniexamp.html I can't follow it exactly because I'm doing it in Eclipse (Is this a bad word in this forum?) I created and compilled the C file per the instructions. I add the path that the .so file is on to the java.library.path in Eclipse by going to Run -> Run... -> Arguments -> VM Arguments and adding -Djava.library.path=/path/to/so/file/. I added the lines to check the library path has been set and it is what I would expect (ie it has the path to the .so file) What am I doing wrong? class ReadFile   More>>

I am trying to do a JNI example but getting an UnsatisfiedLinkError.
I am following the example at:
http://java.sun.com/developer/onlineTraining/Programming/JDCBook/jniexamp.html
I can't follow it exactly because I'm doing it in Eclipse (Is this a bad word in this forum?)
I created and compilled the C file per the instructions.


I add the path that the .so file is on to the java.library.path in Eclipse by going to Run -> Run... -> Arguments -> VM Arguments and adding -Djava.library.path=/path/to/so/file/. I added the lines to check the library path has been set and it is what I would expect (ie it has the path to the .so file)


What am I doing wrong?


class ReadFile

{
// native method declaration
native byte[] loadFile(String name);

// load the library
static
{
System.loadLibrary("libnativelib"); // error here
}

public static void main(String args[])
{
String libraryPath = System.getProperty("java.library.path",".");
System.out.println ("library path = " + libraryPath);

byte buf[];

// create class instance
ReadFile mappedFile=new ReadFile();

// call native method to load ReadFile.java
buf=mappedFile.loadFile("ReadFile.java");

// print contents of ReadFile.java
for(int i=0;i
{
System.out.print((char)buf);
}
}


}

   <<Less
About | Sitemap | Contact