Results 1 to 4 of 4

Thread: JNI samples

  1. #1
    redforce.bala is offline Member
    Join Date
    Sep 2010
    Posts
    23
    Rep Power
    0

    Question JNI samples

    Hi all

    I tried to execute the JNI helloworld program.I am getting error in the last step of the execution.I think the dll is not linking to the program.Can anyone help me to do this.Error is given below.Thanks in advance..

    D:\work\Java>java -classpath . test
    Exception in thread "main" java.lang.UnsatisfiedLinkError: D:\work\Java\test.dll: Can't find dependent libraries
    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 test.<clinit>(test.java:7)
    Could not find the main class: test. Program will exit.

  2. #2
    chyrl is offline Senior Member
    Join Date
    Mar 2010
    Location
    Manila, Philippines
    Posts
    257
    Rep Power
    5

    Default

    Can you post your SSCCE for further guide?
    Every project, package, class, method, variable, syntax, algorithm, etc.
    are registered in my memory bank. Thanks to this thread.

  3. #3
    redforce.bala is offline Member
    Join Date
    Sep 2010
    Posts
    23
    Rep Power
    0

    Question

    Here is the source code

    test.java

    class test
    {
    private native void print();

    static
    {
    System.loadLibrary("test");
    }
    public static void main(String[] a)
    {
    new test().print();
    }

    }


    test.h

    /* DO NOT EDIT THIS FILE - it is machine generated */
    #include <jni.h>
    /* Header for class test */

    #ifndef _Included_test
    #define _Included_test
    #ifdef __cplusplus
    extern "C" {
    #endif
    /*
    * Class: test
    * Method: print
    * Signature: ()V
    */
    JNIEXPORT void JNICALL Java_test_print
    (JNIEnv *, jobject);

    #ifdef __cplusplus
    }
    #endif
    #endif

    test.c

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

    JNIEXPORT void JNICALL
    Java_test_print(JNIEnv *env,jobject obj)
    {
    printf("Hello world!\n");
    return;
    }

    After this process i created the dll and finally while running the program i got the above mentioned error.

  4. #4
    chyrl is offline Senior Member
    Join Date
    Mar 2010
    Location
    Manila, Philippines
    Posts
    257
    Rep Power
    5

    Default

    Maybe the directory of test.dll isn't at the proper library path.
    Every project, package, class, method, variable, syntax, algorithm, etc.
    are registered in my memory bank. Thanks to this thread.

Similar Threads

  1. How to plot graph in java for given samples
    By annesteve31 in forum New To Java
    Replies: 27
    Last Post: 11-29-2009, 09:27 PM
  2. Java cert exam samples
    By orchid in forum New To Java
    Replies: 5
    Last Post: 06-04-2007, 09:33 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •