This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

file not found for JNI


Hey,

I'm trying to compile (to native) an application that uses JNI, and I'm not
having any luck.  I'm using cygwin and run the following commands (which all
execute without problems):

gcj -C test.java
gcjh -jni test
gcc -shared -o libtest.dll test.c
gcj -fjni -o test.exe --main=test -L. -ltest test.java

At this point I have a file called test.exe and libtest.dll.  However, when
I attempt to execute test.exe, I get the message:

Exception in thread "main" java.lang.UnsatisfiedLinkError: test: file not
found

I've tried renaming this file every combination I can think of, but none
seem to work.

Here is my test.java:

public class test {
   static { System.loadLibrary("test"); }
   public static void main(String [] args) {
      System.out.println(new test().msg());
   }
   public native String msg();
}

Here is my test.c:

#include <jni.h>
#include "test.h"

JNIEXPORT jstring Java_test_test (JNIEnv *env, jobject obj) {
   return (*env)->NewStringUTF(env,"JNI WORKED!!!");
}

Is this a bug in the way loadLibrary() works?  FYI:  I've tried replacing my
call to load() and using the full path of the dll, but that also returned a
"file not found" message.

Any help would be much appreciated!

David McCullars





**********************************************************************
The information contained in this communication is
confidential, is intended only for the use of the recipient
named above, and may be legally privileged.
If the reader of this message is not the intended
recipient, you are hereby notified that any dissemination, 
distribution, or copying of this communication is strictly
prohibited.
If you have received this communication in error,
please re-send this communication to the sender and
delete the original message or any copy of it from your
computer system. Thank You.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]