JNI  UnsatisfiedLinkError

Hi everybody.
i've got a problem running a simple example of JNI.
I'm trying to call the method MessageBox of user32.dll, that is placed on system32 of course.
This is the code:
import java.io.*;
public class NativeMFCMsg{
static {
try {
//System.loadLibrary("user32");
System.load("c:\\winnt\\system32\\user32.dll");
System.out.println("Library user32 Loaded");
}catch(Exception e){
e.printStackTrace();
public native int MessageBox( int hWnd,String lpText,String lpCaption,int uType );
public static void main(String[] args){
try {
new NativeMFCMsg().MessageBox(0,"Hello","Caption",0);
}catch(UnsatisfiedLinkError ex){
ex.printStackTrace();
System.out.println("Error " + "\n" + ex.toString());
System.exit(1);
the load or the loadLibrary methods works fine ... the problem is when i call the MessageBox ... don't know why ? i've read the JNI tutorial from sun and i think that there is everything correct but ... it's obvious that i'm wrong ...
please help.
Regards, Roberto.

First, you could use the -verbose option of the jvm to try to get some more info. Is there is some other dll that it can't find ?
Then, you could check your method signature. Make sure you use the prototypes from the JNI-created header file exactly.
In particular, did you supply the fully qualified name (including the package name) of your class to javah (e.g. yourPackage.yourClass).
The mangled name (in yourPackage_yourClass.h) should look like this:
Ljava_yourPackage_yourClass_yourMethod

Similar Messages

  • JNI UnsatisfiedLinkError in Weblogic 5.1.0 SP 8

    I am running Weblogic 5.1.0 with service pack 8 on solaris. We are using a web application called ecare. Servlets are under:myserver/ecare/web-inf/classes/servletsThe JavaBean that uses JNI to connect to the C code is under:myserver/ecare/web-inf/classes/JNIThe C library is under:myserver/ecare/web-inf/libThis path is added on LD_LIBRARY_PATHThe JavaBeans although it manages to load the library successfully it fails on the first native function call with the error java.lang.UnsatisfiedLinkError: functionnameI've tested that code before adding it to our weblogic implementation, by using a test java program that made the native calls to the library and that worked fine.The JavaBean that calls the c library is in package JNI. I've tried using javah from the classes directory (parent of JNI, and in classpath) which produced a header file with the function names that included the package name JNI, but that did not help.Browsing through the emails on this newsgroup I've noticed that there were a few people with the same problem as me, but I did not manage to find any solution to the problem.Any help would be greatly appreciated. I am looking forward to hearing from any of you.Kind Regards,Mike

    For me it seems that you have not created the native method header file correctly.
    To create the header file correctly you have to call the javah compiler in the following
    way:
    javah -jni fullpackagename.NativeClassName
    then you get the right package name in your header file.
    This has solved the UnsatisfiedLinkError at the first call of my nativ method call.
    I hava not tested this within a EJB. It's still a "normal" programm.
    Greetings
    Johannes

  • JNI UnsatisfiedLinkError - one more

    Hi there,
    As i saw a lot of problem concerning use of JNI and shared library i've got same problems. All i could see about how to do the right way is not enough ...
    My java class, .c, .h are in the right writes. All is well compiled, with package name. Libraries path are well set, even LD_LIBRARY PATH and SHLIB_PATH as i'm working on hp-ux. The library exists, has the right name
    and when executing i've got the :
    Exception occurred during event dispatching :
    java.lang.UnsatisfiedLinkError: no ArtStart in java.library.path
    at java.lang.ClassLoader.loadLibrary(...)
    at java.lang.Runtime.loadLibrary0(...)
    at java.lang.System.loadLibrary(...)
    etc ...
    So is there any way to make it working ???
    Chris

    I was only able to load libraries using System.load("<full path to lib>"); . This was on Win 2000 though.
    If you are using packages, please read this from a previous post:
    When you package your class there are 2 things to look out for. First in order to generate a proper package-named header you must use "javah -jni mypackage.myclass" at the head of the appropriate classpath. This will create the mypackage_myclass.h header file. Second, you have to change the names appropriately in your calls. Non-packaged methods have the form JAVAMYCLASS_MYMETHOD. Packaged methods have the form JAVAMYPACKAGE_MYCLASS_MYMETHOD.
    If you use dumpbin/EXPORTS on DOS or an equivalent on UNIX on your dll, you can see what the export method name really is. Also be sure to get rid of any old dll.
    Good luck.
    Frank L. Hood
    Polexis
    ---------------------------------------------

  • UnsatisfiedLinkError with JNI

    I have what I think is a strange problem, because last year this program worked, and this year it doesn't. Obviously something has changed, but I can't figure out what.
    What I am doing here is using the JNI to call a Native Method to get some data from a A/D.
    However, now when I try to call that method, I get the following error:
    Caused by java.lang.UnsatisfiedLinkError; fileiotest.dllinterface.startget()UAlso, here is the code for the dllinterface file. It's simple and short, so I think I can paste the whole thing
    package fileiotest;
    * @author Owner
    public class dllinterface {
        public native void startget(int channels);
        public native float[] getpoint(int channels);
        public native float[] gettimepoint(int channels);
        public native void stopget();
        private static dllinterface DI;
        private float newtempfloat[] = new float[9];
        static {
         System.loadLibrary("daqdll");//This is firstJNI.DLL
         DI = new dllinterface();
         /*if generated by borland
         System.loadLibrary("firstjni");//This is firstjni.dll
        public void start_daq(int channels)
         DI.startget(channels);
        public void stop_daq()
           DI.stopget();
        public float[] get_data_point(int channels)
          newtempfloat = DI.getpoint(channels);
          return newtempfloat;
        public float[] get_data_time_point(int channels)
          newtempfloat = DI.gettimepoint(channels);
          //System.out.println(newtempfloat[channels]);
          return newtempfloat;
    }Edited by: Mike_Keller on Aug 2, 2010 8:02 AM

    You are loading the dll successfully.
    So that means the dll changed.

  • Weblogic server 8.1 JNI module deployment java.lang.UnsatisfiedLinkError

    This is on the weblogic 8.1 Solaris platform.
    We have a module in our application which uses the native shared library and makes JNI called from the J2EE application. We have added the .so files to the LD_LIBRARY_PATH environment variable in our managed server startup scripts. When we start our servers the module works fine. But when we redeploy the J2EE application, the java code is changed but we start getting java.lang.UnsatisfiedLinkError exception when the module is invoked. We are using the staged mode for deployment. We have to shut down the managed servers and restart them every time for this module to start working after the redeployment of the J2EE application.
    Is this a known problem with the JNI based application. Is there any setting that we are missing? Has this problem been fixed in any of the service packs?

    Have you checked to see if your file descriptor setting is set high enough? Disabling native IO is not a very good solution as it will drastically reduce performance.
    --Raheem                                                                                                                                                                                                                                                                                                                                                                   

  • JNI exception, java.lang.UnsatisfiedLinkError

    Hi,
    I�m trying to call a native method with JNI and the following exception occurs when I try to call the native method setFileName:
    Exception occurred during event dispatching:
    java.lang.UnsatisfiedLinkError: setFileName
    The dll where this method is defined is in the directory c:/winnt/system32, the Windows default path.
    Why this exception occurs?
    Thanks in advance
    carlos

    The basic reasons why this would occur are
    1. There is something wrong with the path to the dll.
    2. You didn't do a "loadLibrary()" on the dll before you called the native method.
    3. There is some disconnect between the expected signature of the native method, and the way it is defined in the dll.
    If this doesn't help, thenI suggest you post a bit of code (loadLibrary, native method signature, C function signature).

  • UnsatisfiedLinkError for JNI DLL compiled with vs2008 express

    I am trying to create a JNI DLL using Visual Studio 2008 Express.
    I have read several places where -MD causes JNI problems but from what I've read, I need this option to create the DLL properly.
    The DLL does get built cleanly and I have created a simple C application (obviously not calling the JNI functions themselves but the other functions that are in the DLL). This application runs with no problems.
    As soon as I try to use the DLL with JNI, I get an UnsatisfiedLinkError: Can't find dependent libraries.
    I have used Dependency Walker on the C application I created and it finds no errors; however, if I run it on the DLL itself, it does report an error trying to find msvcr90.dll which is in the winsxs directory under c:\windows so I assume this is the problem dependency.
    I am running this on the same computer that has Visual Studio 2008 Express SP1 installed. This is a Windows XP Service Pack 3 computer running JDK 1.6.0_14.
    Any help would be greatly appreciated.
    Thanks

    Right or wrong, I include some library files into my link statement (it's the only way I could find to clear up your question). I link in some standard window libraries as well as some of my own DLL whose functions are used by this DLL. I use a makefile to build my code.
    Here is a compile statement and the link statement for my DLL:
    cl.exe -I c:\progra~1\micros~1.0\vc\include -I c:\progra~1\mi2578~1\windows\v7.0\include -I c:/progra~1/java/jdk1.6.0_14/include -I c:/progra~1/java/jdk1.6.0_14/include/Win32 -I S:/wlw/Develop/Src/Include -I S:/wlw/Products/Src/Include -I S:/wlw/Products/Src/Include -I S:/wlw/Products/Src/LibSrc/RTA/Client/Include/Example -I S:/wlw/Products/Src/LibSrc/RTA/Client/Include/System -I S:/wlw/Products/Src/LibSrc/RTA/Client/Include/User -I S:/wlw/Products/Src/LibSrc/RTA/Server/Include/System -I S:/wlw/Products/Src/LibSrc/RTA/Server/Include/User -DRTA_DLL -D_BIND_TO_CURRENT_VCLIBS_VERSION -Zp4 -DWIN32 -D__WIN32__ -DWINVER=0x0400 -D_WIN32_WINNT=0x0400 -D_USE_32BIT_TIME_T -D_CRT_SECURE_NO_WARNINGS -nologo -W3 -Od -EHsc -MD -Z7 -c buildDate.c
    link.exe -incremental:no -nologo -debug kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib -dll -out:S:/wlw/Products/Obj/Win32/Lib/rta.dll -implib:S:/wlw/Products/Obj/Win32/Lib/rta.lib eipc_client.obj eipc_usersys.obj eips_pccc.obj eips_cnxn.obj eips_cpf.obj eips_encap.obj eips_iomsg.obj eips_rtasys.obj eips_timer.obj rta_utils.obj eips_userdf1.obj eips_userobj.obj eips_usersock.obj eips_usersys.obj jniRta.obj jniRtaPlc.obj jniRtaPlcAddress.obj qcRta.obj qcRtaPlcAddressLink.obj qcRtaPlcLink.obj qcRtaProcess.obj qcRtaRead.obj qcRtaSlcRead.obj qcRtaSlcWrite.obj qcRtaState.obj qcRtaTimer.obj qcRtaWrite.obj Q:/Develop/Obj/Win32/Lib/tcpipNet.lib Q:/Develop/Obj/Win32/Lib/linkList.lib Q:/Develop/Obj/Win32/Lib/stdUtils.lib buildDate.obj
    mt -manifest S:/wlw/Products/Obj/Win32/Lib/rta.dll.manifest -outputresource:S:/wlw/Products/Obj/Win32/Lib/rta.dll;2

  • "Exception in thread "main" java.lang.UnsatisfiedLinkError:"  JNI in Linux

    Hi,
    I am writing a simple program to understand how JNI works so that I can use this concept to develop a project. But after running the simple code,
    It gives the following error:
    Exception in thread "main" java.lang.UnsatisfiedLinkError: sum
    at TestJni.main(testJni.java:25)
    My Java code is:
    import java.io.*;
    import java.util.*;
    class TestJni
    // Try to load the native Code library for user Authentication.
    static
    try
    System.loadLibrary( "test" );
    catch( UnsatisfiedLinkError e )
    System.out.println("Could not load native code for user authentication." );
    System.exit(1);
    public static void main( String [] args )
    //TestJni obj = new TestJni();
    System.out.println(TestJni.sum(2, 3));
    public static native int sum( int x, int y );
    TestJni.h looks like:
    /* DO NOT EDIT THIS FILE - it is machine generated */
    #include <jni.h>
    /* Header for class TestJni */
    #ifndef IncludedTestJni
    #define IncludedTestJni
    #ifdef __cplusplus
    extern "C" {
    #endif
    * Class: TestJni
    * Method: sum
    * Signature: (II)I
    JNIEXPORT jint JNICALL Java_TestJni_sum
    (JNIEnv *, jclass, jint, jint);
    #ifdef __cplusplus
    #endif
    #endif
    and my C++ code is:
    #include <jni.h>
    #include "TestJni.h"
    #include <stdio.h>
    JNIEXPORT jint JNICALL Java_TestJni_sum(JNIEnv *env, jclass obj, jint x, jint y)
    printf("Inside the native function\n");
    return (x + y);
    Then I am generating my .so file as:
    g++ -o libtest.so sum.cpp -shared -fpic -lcrypt -I//usr/lib/j2se/1.4/include -I/usr/lib/j2se/1.4/include/linux
    and copying the libtest.so file into the folder where I have my TestJni.class file. Then running the java code by:
    java TestJni
    but it gives the "UnsatisfiedLinkError". What to do? :( I have spend 2 days now to solve this problem but I am not getting it.
    I am using ubuntu 7.10 as my OS.
    Please let me know if you can help.

    Thanks for your response. I found that, when I copied the shared library to /usr/lib and
    did: ldconfig -n /usr/lib it worked
    But the problem is, this is my computer, but the computers that I am going to run my actual
    JNI application, have restrictive permission. Could anyone please let me know how I can
    do the work without ldconfig. I mean is there anyway I can configure my .so file's path without
    copying it into the /usr/lib folder and without ldconfig?
    I will appreciate any reply. Thanks.

  • (HelP)got an  unsatisfiedlinkerror when using the jni

    I am now working on a jni project and get the unsatisfiedlinkerror. But after I browse this forum, I do not get any useful information.
    my java code:
    package graphmining.cliquer;
    public class WClique {
         * @param args
         public static void main(String[] args) {
              // TODO Auto-generated method stub
              WClique wc = new WClique();
              wc.buildGraph(4);
         static
              System.loadLibrary("WClique");
         public native static void buildGraph(int vertexNumber);
         public native static void addEdge(int i, int j);
         public native static void setEdgeNumber(int e);
         public native static int isAboveThreshold(int threshold);
    I use "javah -jni graphmining.cliquer. WClique" get the WClique.h file.
    // begin of WClique.h file;
    /* DO NOT EDIT THIS FILE - it is machine generated */
    #include <jni.h>
    /* Header for class graphmining_cliquer_WClique */
    #ifndef Includedgraphmining_cliquer_WClique
    #define Includedgraphmining_cliquer_WClique
    #ifdef __cplusplus
    extern "C" {
    #endif
    * Class: graphmining_cliquer_WClique
    * Method: buildGraph
    * Signature: (I)V
    JNIEXPORT void JNICALL Java_graphmining_cliquer_WClique_buildGraph
    (JNIEnv *, jclass, jint);
    * Class: graphmining_cliquer_WClique
    * Method: addEdge
    * Signature: (II)V
    JNIEXPORT void JNICALL Java_graphmining_cliquer_WClique_addEdge
    (JNIEnv *, jclass, jint, jint);
    * Class: graphmining_cliquer_WClique
    * Method: setEdgeNumber
    * Signature: (I)V
    JNIEXPORT void JNICALL Java_graphmining_cliquer_WClique_setEdgeNumber
    (JNIEnv *, jclass, jint);
    * Class: graphmining_cliquer_WClique
    * Method: isAboveThreshold
    * Signature: (I)I
    JNIEXPORT jint JNICALL Java_graphmining_cliquer_WClique_isAboveThreshold
    (JNIEnv *, jclass, jint);
    #ifdef __cplusplus
    #endif
    #endif
    // end the wclique.h file
    Then, I build the .c file.
    //the .c file
    /* DO NOT EDIT THIS FILE - it is machine generated */
    #include <jni.h>
    #include "WClique.h"
    /* Header for class graphmining_cliquer_WClique */
    #ifndef Includedgraphmining_cliquer_WClique
    #define Includedgraphmining_cliquer_WClique
    #ifdef __cplusplus
    extern "C" {
    #endif
    * Class: graphmining_cliquer_WClique
    * Method: buildGraph
    * Signature: (I)V
    JNIEXPORT void JNICALL Java_graphmining_cliquer_WClique_buildGraph
    (JNIEnv * env, jclass cl, jint i){
         int z = i;
    * Class: graphmining_cliquer_WClique
    * Method: addEdge
    * Signature: (II)V
    JNIEXPORT void JNICALL Java_graphmining_cliquer_WClique_addEdge
    (JNIEnv * env, jclass cl, jint i, jint j){
         int zz = i;
         int zz
    * Class: graphmining_cliquer_WClique
    * Method: setEdgeNumber
    * Signature: (I)V
    JNIEXPORT void JNICALL Java_graphmining_cliquer_WClique_setEdgeNumber
    (JNIEnv * env, jclass cl, jint j){
    * Class: graphmining_cliquer_WClique
    * Method: isAboveThreshold
    * Signature: (I)I
    JNIEXPORT jint JNICALL Java_graphmining_cliquer_WClique_isAboveThreshold
    (JNIEnv * env, jclass cl, jint j){
         return 0;
    #ifdef __cplusplus
    #endif
    #endif
    //end the WClique. c file
    My program is running in a linux pc.
    And I use the commands
    "gcc -I"/java/include" -I"/java/include/linux" -o WClique.o -c WClique.c
    gcc -shared -o WClique.so WClique.o "
    to get the .so file.
    Then, I call the .so file from the original java file. However, it always returns the "unsatisfiedlinkerror". Note that I have used the correct library path and function name. I do not know what's wrong with it. Any one can help it?

    I have named the generated file as libWClique.so.

  • Help needed with JNI -  java.lang.UnsatisfiedLinkError

    I need some help with JNI. I am running on Sun Solaris 7 using their CC compiler. I wrote a simple java program that calls a native method to get a pid. Everything work until I use cout or cerr. Can anyone help? Below is what I am working with.
    Note: The application works. The problem is when the C++ code tries to display text output.
    My error log is as follows:
    java Pid
    Exception in thread "main" java.lang.UnsatisfiedLinkError: /home/dew/test/libPid.so: ld.so.1: /usr/j2se/bin/../bin/sparc/native_threads/java: fatal: relocation error: file /home/dew/test/libPid.so: symbol __1cDstdEcerr_: referenced symbol not found
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1382)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1306)
    at java.lang.Runtime.loadLibrary0(Runtime.java:749)
    at java.lang.System.loadLibrary(System.java:820)
    at Pid.<clinit>(Pid.java:5)
    Pid.java
    ========
    * Pid: Obtains the pid from the jvm.
    class Pid {
    static { System.loadLibrary("Pid"); }
    public native int getPid();
    public static void main(String args[])
    System.out.println("Before construction of Pid");
    Pid z = new Pid();
    System.out.println(z.getPid());
    z = null;
    Pid.cpp
    =========
    * Native method that obtains and returns the processid.
    #include "Pid.h"
    #include "unistd.h"
    #include <iostream.h>
    JNIEXPORT jint JNICALL Java_Pid_getPid(JNIEnv *env, jobject obj) {
    /* cout << "Getting pid\n"; */
    cerr << "Getting pid\n";
    /* printf("Getting pid\n"); */
    return getpid();

    I forgot to include my build information.
    JAVA_HOME = /usr/j2se/
    LD_LIBRARY_PATH = ./:/opt/readline/lib:/opt/termcap/lib:/usr/bxpro/xcessory/lib:/${JAVA_HOME}/lib:/usr/RogueWave/workspaces/SOLARIS7/SUNPRO50/0d/lib:/usr/RogueWave/workspaces/SOLARIS7/SUNPRO50/3d/lib:/usr/sybase/lib
    javac Pid.java
    javah Pid
    CC -G -I${JAVA_HOME}/include -I${JAVA_HOME}/include/solaris Pid.cpp -o libPid.so
    Thanks again,
    Don

  • UnsatisfiedLinkError while calling a JNI Method

    Hi everyone,
    I have been struggling with this problem for two weeks now. I have a third party SDK that provides JNI library and all i need to do is implement the SDK, load the JNI library they have provided, and call the JNI methods. I was successfully able to load the JNI library and call the JNI methods when i don't put the classes in the package. But when i put the classes in a package then the library gets loaded successfully but an unsatisfiedLinkError occurs when calling the JNI methods. Please help!!! Please remember that the JNI library is provided by the third party vendor and I don't need to write the C/C++ code or call javah to create a .h file and then a c/c++ file.
    This is the error i get:
    Exception in thread "main" java.lang.UnsatisfiedLinkError: ss.tts.JNILayer.InitDFTTSEngineEx3(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[I[I)V
         at ss.tts.JNILayer.InitDFTTSEngineEx3(Native Method)
         at ss.tts.Speech.test(Speech.java:854)
         at ss.tts.SSMain.main(SSMain.java:13)
    The three classes are SSMain, Speech, and JNILayer. JNILayer has the jni methods, speech calls the jni method, and SSMain is main class.
    Thank you in advance.

    which ever class which contains the "InitDFTTSEngineEx3" method. should not be altered, even its package should not be altered.[same for other class which has the native method declared in them]
    because in native code jni method signatures will be based on the java class's fully qualified name.
    so when you change the package the FQN will change and no matching method for this
    ss.tts.JNILayer.InitDFTTSEngineEx3(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[I[I)V
    will be found in native code.
    i hope u understood.

  • UnsatisfiedLinkError in JNI Tutorial

    I just tried the "JNI Tutorial" (java.sun.com/docs/books/tutorial/native1.1/stepbystep), but it doesn't work on my machine. I'm getting:
    java.lang.UnsatisfiedLinkError: displayHelloWorld
         at jnitest.HelloWorld.displayHelloWorld(Native Method)
         at jnitest.Frame1._buttonHelloWorldDll_actionPerformed(Frame1.java:91)
         at jnitest.Frame1$2.actionPerformed(Frame1.java:51)
         at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1764)
         at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1817)
         at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:419)
         at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257)
         at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245)
         at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:227)
         at java.awt.Component.processMouseEvent(Component.java:5134)
         at java.awt.Component.processEvent(Component.java:4931)
         at java.awt.Container.processEvent(Container.java:1566)
         at java.awt.Component.dispatchEventImpl(Component.java:3639)
         at java.awt.Container.dispatchEventImpl(Container.java:1623)
         at java.awt.Component.dispatchEvent(Component.java:3480)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3450)
         at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3165)
         at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3095)
         at java.awt.Container.dispatchEventImpl(Container.java:1609)
         at java.awt.Window.dispatchEventImpl(Window.java:1590)
         at java.awt.Component.dispatchEvent(Component.java:3480)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:450)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:197)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)
    I'm working with NT4, JBuilder, JDK 1.4.1_02 and Visual Studio 6. I placed the dll in my windows\system32 directory. What can I do?
    Thank you for any ideas ...

    java.lang.UnsatisfiedLinkError: displayHelloWorld
    Hi crz,
    Hari has mentioned it correctly.
    I am just going to ask you to perform one more check on the code.
    you might have defined the displayHelloWorld() in some Java class.
    Please verify whether the signature is not changed in the JNI interfacing. Because it will except the same signature as it is in Java.
    Can you verify this?
    And instead of copying the DLL to the windows/system directory,
    try mentioning the "-Djava.library.path=<Dir of the DLL>" while running the Java program that will inturn call the native method.
    Hope this helps.
    Best wishes,
    LathaDhamo.

  • UnsatisfiedLinkError System.loadLibrary Windows CE JNI

    I am writing a java application for a Siemens SIMpad SL4 (Windows CE 3.0,Jeode EVM 1.9)
    I have a dll (mylib.dll) compiled with embedded visual c++ containing native functions.
    It is placed in the \windows directory.
    When I try to load the dll with System.loadLibrary(), I allways get an java.lang.UnsatisfiedLinkError.
    Things I have tried:
    System.loadLibrary("mylib");
    System.loadLibrary("mylib.dll");
    System.loadLibrary("\\windows\\mylib");
    System.loadLibrary("\\windows\\mylib.dll");
    java -Djava.library.path=\windows ...
    Different Directories for the dll (\windows, \, \windows\lib)
    Using other "CLASSPATH".
    Using other "PATH".
    But nothing worked.
    When I load a system dll (e.g. smartcard.dll) with System.loadLibrary("smartcard"), the dll
    is loaded succesfully. Only "self-compiled" libraries are not loaded.
    When I load the dll from a c++ test programm(HINSTANCE handle = LoadLibrary(L"mylib"))
    my library is loaded sucessfully.
    So it seems to be a java only problem.
    Any Ideas ?
    Thanks

    I tried to load different dlls with System.loadLibrary() and used the -verbose option of the jvm.
    A preinstalled dll: System.loadLibrary("winscard"); (Which has nothing to do at all with JNI)
    The "verbose" said: [Loaded Library \Windows\bin\winscard.dll]
    So the library seems to load succesfully.
    Another preinstalled dll: System.loadLibrary("finance");
    The "verbose" said: [Loaded Library \Windows\bin\finance.dll]
    The library loaded ok as well.
    A non exisiting dll: System.loadLibrary("nothing");
    The result was a "java.lang.UnsatisfiedLinkError nothing.dll; library not found"
    An empty test dll created with the dll wizard of embedded visual c++: System.loadLibrary("empty");
    (The dll is in the \Windows directory)
    The result was a "java.lang.UnsatisfiedLinkError empty.dll; library not found"
    A selfmade "JNI" dll: System.loadLibrary("mylib");
    The result is again a "java.lang.UnsatisfiedLinkError mylib.dll; library not found"
    So I don't think it's a problem with the method names.
    Thanks anyway.

  • Couldn't Load DLL and Call JNI in Portal Servlet !!!

    Hello,
    I'm trying to write a small test servlet in portal which will call functions in a DLL using JNI. Here is my source code. I put my DLL in \Window\system32, usr/sap/J2E/JC01/j2ee/os_libs, even included into my portal project \PORTAL-INF\lib. But everytime when I try to preview my page, I got the following error and I couldn't find the log file specified in the error message. Please help me out. Thanks a lot!
    Portal Runtime Error
    An exception occurred while processing a request for :
    iView : N/A
    Component Name : N/A
    MyTestDLL.
    Exception id: 12:25_23/12/06_0029_11241950
    See the details for the exception ID in the log file
    Source Code:
    import com.sapportals.portal.prt.component.*;
    public class CIViewTest extends AbstractPortalComponent
         public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)
              response.write("Hello From Java Servlet!!!\n");
         static {
              try {
                   Runtime.getRuntime().loadLibrary("MyTestDLL");
    // I've also tried System.LoadLibrary("MyTestDLL");
              } catch (UnsatisfiedLinkError ule) {
                   throw ule;

    Nobody used JNI in Portal Servlet??? Please advice. Thanks!

  • Problem with JNI and Tomcat in windows

    Hello guys...
    I have the following problem.
    I used Tomcat 4 and I have following ApiEncriptacion class, in package com.servipag.sts;
    package com.servipag.sts;
    class ApiEncriptacion
         public native String encripta(String texto, String ubicacionLlavePublica, String semilla);
         static
              System.loadLibrary("apisdark");
         public native String desencripta(String texto, String ubicacionLlavePrivada);
         static
              System.loadLibrary("apisdark");
    the LD_LIBRARY_PATH is set in following dir c:\tomcat\bice
    the dll this in the following path = c:\tomcat\bice\apisdark.dll
    I run Tomcat at the following way..
    C:\jdk1.4\bin\java.exe -jar -Djava.library.path="c:\tomcat\bice" -Duser.dir="C:\Tomcat" "C:\Tomcat\bin\bootstrap.jar" start
    but, still appear the error:
    java.lang.UnsatisfiedLinkError: encripta
         at com.servipag.sts.ApiEncriptacion.encripta(Native Method)
         at com.servipag.sts.ServiciosServiPagImpl.rescatarFirma(ServiciosServiPagImpl.java:2143)
         at com.servipag.sts.ServiciosServiPagImpl.pagarCuenta(ServiciosServiPagImpl.java:310)
         at org.apache.jsp.SBCO_0005flogin_0005fbice_0005f4$jsp._jspService(SBCO_0005flogin_0005fbice_0005f4$jsp.java:265)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:201)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2343)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1012)
         at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1107)
         at java.lang.Thread.run(Thread.java:536)
    please help me
    Luis Navarro.
    Chile

    ApiEncripatcion.h
    /* DO NOT EDIT THIS FILE - it is machine generated */
    #include <jni.h>
    /* Header for class ApiEncriptacion */
    #ifndef IncludedApiEncriptacion
    #define IncludedApiEncriptacion
    #ifdef __cplusplus
    extern "C" {
    #endif
    * Class: ApiEncriptacion
    * Method: encripta
    * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
    JNIEXPORT jstring JNICALL Java_ApiEncriptacion_encripta
    (JNIEnv *, jobject, jstring, jstring, jstring);
    * Class: ApiEncriptacion
    * Method: desencripta
    * Signature: (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
    JNIEXPORT jstring JNICALL Java_ApiEncriptacion_desencripta
    (JNIEnv *, jobject, jstring, jstring);
    #ifdef __cplusplus
    #endif
    #endif
    ApiEncriptacion.c
    #include "jni.h"
    #include <stdio.h>
    #include "files.h"
    #include "hex.h"
    #include "rsa.h"
    #include "randpool.h"
    USING_NAMESPACE(CryptoPP)
    USING_NAMESPACE(std)
    void GenerateRSAKey(unsigned int keyLength, const char privFilename, const char pubFilename, const char *seed);
    char RSAEncryptString(const char pubFilename, const char seed, const char message);
    char RSADecryptString(const char privFilename, const char *ciphertext);
    JNIEXPORT jstring JNICALL
    Java_ApiEncriptacion_encripta(JNIEnv *env, jobject obj, jstring texto, jstring ubicacionLlavePublica, jstring semilla)
         try
              char *ciphertext = RSAEncryptString(ubicacionLlavePublica, semilla, texto);
              delete [] ciphertext;
              return(ciphertext);
         catch(CryptoPP::Exception &e)
              return ("");
         catch(std::exception &e)
              return ("");
         catch(...)
              return ("");
    JNIEXPORT jstring JNICALL
    Java_ApiEncriptacion_desencripta(JNIEnv *env, jobject obj, jstring texto, jstring ubicacionLlavePrivada)
         try
              char *decrypted = RSADecryptString(ubicacionLlavePrivada, texto);
              return(decrypted);
         catch(CryptoPP::Exception &e)
              return ("");
         catch(std::exception &e)
              return ("");
         catch(...)
              return ("");
    int main()
         return(0);     
    void GenerateRSAKey(unsigned int keyLength, const char privFilename, const char pubFilename, const char *seed)
         RandomPool randPool;
         randPool.Put((byte *)seed, strlen(seed));
         RSAES_OAEP_SHA_Decryptor priv(randPool, keyLength);
         HexEncoder privFile(new FileSink(privFilename));
         priv.DEREncode(privFile);
         privFile.MessageEnd();
         RSAES_OAEP_SHA_Encryptor pub(priv);
         HexEncoder pubFile(new FileSink(pubFilename));
         pub.DEREncode(pubFile);
         pubFile.MessageEnd();
    char RSAEncryptString(const char pubFilename, const char seed, const char message)
         FileSource pubFile(pubFilename, true, new HexDecoder);
         RSAES_OAEP_SHA_Encryptor pub(pubFile);
         if (strlen(message) > pub.MaxPlainTextLength())
              cerr << "message too long for this key\n";
              abort();
         RandomPool randPool;
         randPool.Put((byte *)seed, strlen(seed));
         char outstr = new char[2pub.CipherTextLength()+1];
         pub.Encrypt(randPool, (byte *)message, strlen(message), (byte *)outstr);
         HexEncoder hexEncoder;
         hexEncoder.Put((byte *)outstr, pub.CipherTextLength());
         hexEncoder.MessageEnd();
         hexEncoder.Get((byte *)outstr, 2*pub.CipherTextLength());
         outstr[2*pub.CipherTextLength()] = 0;
         return outstr;
    char RSADecryptString(const char privFilename, const char *ciphertext)
         FileSource privFile(privFilename, true, new HexDecoder);
         RSAES_OAEP_SHA_Decryptor priv(privFile);
         HexDecoder hexDecoder;
         hexDecoder.Put((byte *)ciphertext, strlen(ciphertext));
         hexDecoder.MessageEnd();
         SecByteBlock buf(priv.CipherTextLength());
         hexDecoder.Get(buf, priv.CipherTextLength());
         char *outstr = new char[priv.MaxPlainTextLength()+1];
         unsigned messageLength = priv.Decrypt(buf, (byte *)outstr);
         outstr[messageLength] = 0;
         return outstr;

Maybe you are looking for