Help needed (the notorious java.lang.UnsatisfiedLinkError)

Hello all.
I'm using Eclipse 3.4.0 on Windows and getting the following error when trying to call a function from a dll which is located in the java project(Test) folder:
Exception in thread "main" java.lang.UnsatisfiedLinkError: Test.hello()V
     at Test.hello(Native Method)
     at Test.main(Test.java:12)Any thoughts about why this problem is happening will be very appreciated.
This is my simple code:
Test.java
public class Test {
     public native void hello();
     static {
          System.loadLibrary("hello");
     public static void main(String[] args) {
          new Test().hello();
}test.cpp
#include <iostream>
#include "Test.h"
JNIEXPORT void JNICALL Java_Test_hello
  (JNIEnv *env, jobject obj)
     std::cout<<"Hello World!"<<std::endl;
}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:    hello
* Signature: ()V
JNIEXPORT void JNICALL  Java_Test_hello
  (JNIEnv *, jobject);
#ifdef __cplusplus
#endif
#endif

Anton1981 wrote:
Hello all.
I'm using Eclipse 3.4.0 on Windows and getting the following error when trying to call a function from a dll which is located in the java project(Test) folder:
Exception in thread "main" java.lang.UnsatisfiedLinkError: Test.hello()V
     at Test.hello(Native Method)
     at Test.main(Test.java:12)
The exception tells you that java did not find the method that it was looking for.
Your library was loaded otherwise another exception would have occurred.
Per your posted code the above exception does not match (line 11 versus line 12). That could just be a cut and paste though.
Presumably you do not have a package in Test because otherwise your C++ code does not match.
Most problems of this sort are because the java method signature does not match the C method signature but your appears to be correct. But to be safe you might want to
1. Delete the dll/h file
2. Delete the class files
3. Recompile java
4. Rerun javah
5. Confirm the signature still matches in your cpp file.
6. Rebuild the dll.
Also try running your code before step 6. If you get an exception besides one that says your library is missing then you still have a library somewhere (which is another source of possible problems.)

Similar Messages

  • 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

  • HELP !!! java.lang.UnsatisfiedLinkError

    Hi All,
    I am getting the error "java.lang.UnsatisfiedLinkError: gcNocompact at
    sun.misc.Gc$Daemon.run(Gc.java:102)" while running the java code in
    AIX. The document said that this is "Thrown if the Java Virtual Machine
    cannot find an appropriate native-language definition of a method
    declared native."
    What is the reason to cause this error ?
    Any suggestion to rectify this.
    Thanks in advance.
    TC8888

    I had the same problem when attempting to use lotus domino toolkit for java... I belive that the AIX is attempting to find a .dll or similar native piece of code, but it cant be found... You need to change your system parameter 'path' (not 'classpath') to include the location of the native code. Check the documentation.

  • [HELP] Need The best Java Web Host

    Hi all,
    I'm looking for the best java web hosting for my commercial web.
    plz, help and show me :(
    thanks for reading
    Pham

    Hi all,
    I'm looking for the best java web hosting for my commercial web.
    plz, help and show me :(
    thanks for reading
    Pham

  • Java.lang.UnsatisfiedLinkError - Urgent please help

    Hi,
    I want to thank you for looking into this problem first.
    I have a very headache problem for the past week. I have an applet that uses JNI to call an existing dll to get the system resources. It works fine on windows 2000 server with IE 5.0. The dll get loaded fine and the function call is working fine.
    However, now I tried to move the applet to an application for me to test with jbuilder, I have problems and I get the error java.lang.UnsatisfiedLinkError: ooInit.
    Does anyone know why this is happening in Jbuilder. I traced to see if the dll get loaded with System.loadlibrary("dll"), and it seems to load the library. But when I call the ooInit() native method, it throws that exception.
    Please help. This will be greatly appreciated and I can do something for you guys in return.
    Thank you so much.
    Regards,
    guna

    Here, for the benefit of others who might search for this, is my approach to resolving this error.
    Two things to note:
    1. I didn't worry about paths, etc. - I was in a hurry so I just copied files into required directories.
    2. I named both the Java and C files "mainFrame". I have not subsequently checked to see if this is required, since it worked for me.
    Summary of getting jni routine to work with Jbuilder:
    created Java project mintest, two principle classes - mainFrame and WelcomeFrame
    key code fragments:
    --------------------------------------- mainFrame --------------------------------------------------
    package mintest;
    import javax.swing.JLabel;
    import javax.swing.JButton;
    import javax.swing.JPanel;
    import java.awt.GridBagLayout;
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseAdapter;
    public class mainFrame {
        boolean packFrame = false;
        WelcomeFrame frame = new WelcomeFrame();
        public static native int cRoutine(int value);
        static {System.loadLibrary("mainFrame"); }
    public mainFrame() {
        //Pack frames that have useful preferred size info, e.g. from their layout
        //Validate frames that have preset sizes
        if (packFrame) {
          frame.pack();
        else {
          frame.validate();
        // Center the frame
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        Dimension frameSize = frame.getSize();
        if (frameSize.height > screenSize.height) {
          frameSize.height = screenSize.height;
        if (frameSize.width > screenSize.width) {
          frameSize.width = screenSize.width;
        frame.setLocation( (screenSize.width - frameSize.width) / 2,
                          (screenSize.height - frameSize.height) / 2);
        frame.setVisible(true);
        try {
          jbInit();
        catch (Exception ex) {
          ex.printStackTrace();
    * Main method
    * @param args String[]
    static public void main(String[] args) {
      try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
      catch (Exception e) {
        e.printStackTrace();
      new mainFrame();
            cRoutine(1);     // this works at this point...
            System.out.println("cRoutine - should be 4: " + cRoutine(3));
      private void jbInit() throws Exception {
    }--------------------------------------- end of mainFrame --------------------------------------------------
    --------------------------------------- (portions of) WelcomeFrame --------------------------------------
    package mintest;
    import java.awt.*;
    ..... more imports, setting up of window, buttons, etc. .... iValue is an integer....
      public void jToggleButton1_mousePressed(MouseEvent e) {
          jToggleButton1.setText("cRoutine in: " + iValue + "  out: " + (iValue = 
                                   mainFrame.cRoutine(iValue)));
      }--------------------------------------- end of (portions of) WelcomeFrame -----------------------------
    mainFrame was compiled with Jbuilder into a class file, makeFrame.class. That was copied into
    the C:\Borland\JBuilder2005\jdk1.4\bin directory, and javah was run to create the C header file:
    javah -jni mainFrame
    This generated:
    --------------------------------------- mainFrame.h generated by javah ----------------------------------
    /* DO NOT EDIT THIS FILE - it is machine generated */
    #include <jni.h>
    /* Header for class mainFrame */
    #ifndef _Included_mainFrame
    #define _Included_mainFrame
    #ifdef __cplusplus
    extern "C" {
    #endif
    * Class:     mainFrame
    * Method:    cRoutine
    * Signature: (I)I
    JNIEXPORT jint JNICALL Java_mainFrame_cRoutine
      (JNIEnv *, jclass, jint);
    #ifdef __cplusplus
    #endif
    #endif--------------------------------------- end of mainFrame.h generated by javah -------------------------
    OKAY, HERE COMES THE CRITICAL STEP. DESPITE THE FACT THE COMMENT SAYS DO NOT EDIT, THIS FILE HAS TO BE EDITED TO INCLUDE THE PACKAGE NAME, LIKE THIS:
    --------------------------------------- modified mainFrame.h ----------------------------------
    /* DO NOT EDIT THIS FILE - it is machine generated */
    #include <jni.h>
    /* Header for class mainFrame */
    #ifndef _Included_mainFrame
    #define _Included_mainFrame
    #ifdef __cplusplus
    extern "C" {
    #endif
    * Class:     mainFrame
    * Method:    cRoutine
    * Signature: (I)I
    JNIEXPORT jint JNICALL Java_mintest_mainFrame_cRoutine
      (JNIEnv *, jclass, jint);
    #ifdef __cplusplus
    #endif
    #endif--------------------------------------- end of modified mainFrame.h -------------------------
    This file is then copied to the C:\Borland\BCC55\Include directory. The C code source is placed
    in the C:\Borland\BCC55\Bin directory. Here is the C code - note that it has the package name in
    the function name:
    --------------------------------------- mainFrame.c ----------------------------------
    #include <mainFrame.h>
    #include <stdio.h>
    #include <string.h>
    /* must link gpib-32.obj for Windows*/
    #include <windows.h> /*if using Windows */
    void main(){
    JNIEXPORT jint JNICALL
    Java_mintest_mainFrame_cRoutine(JNIEnv *env, jobject callingObj,jint invalue)
    return (jint) invalue+1;
    }--------------------------------------- end of mainFrame.c -------------------------
    This is now compiled on the command line (from the C:\Borland\BCC55\Bin directory) using:
    bcc32 -tWD -I\Borland\bcc55\include -L\Borland\bcc55\lib mainFrame.c
    Parameters: -tWD creates Windows DLL file
    -I is path to include directory (this is where mainFrame.h is located)
    -L is path to library directory
    Compilation produces mainFrame.dll in the C:\Borland\BCC55\Bin directory. This is copied to the C:\Borland\JBuilder2005\jdk1.4\jre\bin directory so Jbuilder can find it. Then it works.
    So, the key step is adding the package name after javah has generated the header file (and similarly using the package name in the .c source file.)
    Hope this is useful.

  • Java.lang.UnsatisfiedLinkError: DBDisconnect

    Hi Guys,
    I tried using the Connection pool APIs from db2jcc.jar for DB2 UDB v8.1.
    While i try to execute the following code i got the exception
    java.lang.UnsatisfiedLinkError: DBDisconnect.
    Please help me to find the problem, there is no .dll to be loaded in this regard as for as i concern.
    import java.sql.Connection;
    import java.sql.SQLException;
    import java.sql.DatabaseMetaData;
    import javax.sql.ConnectionEventListener;
    import javax.sql.PooledConnection;
    import javax.sql.ConnectionEvent;
    import com.ibm.db2.jcc.DB2ConnectionPoolDataSource;
    public class DB2Pooling implements ConnectionEventListener {
    private static final String DB_NAME = "SAMPLE";
    private static final String DB_SERVER = "db2admin";
    private static final String DB_USER = "administrator";
    private static final String DB_PASSWORD = "Welcome123";
    public static void main(String[] args) throws SQLException {
         new DB2Pooling().test();
    public void test() throws SQLException {
         System.out.println("1");
         DB2ConnectionPoolDataSource db2ConnectionPoolDataSource = new DB2ConnectionPoolDataSource();
         System.out.println("2");
         db2ConnectionPoolDataSource.setDatabaseName(DB_NAME);
         System.out.println("3");
         db2ConnectionPoolDataSource.setServerName(DB_SERVER);
         System.out.println("4");
         PooledConnection pc = db2ConnectionPoolDataSource.getPooledConnection(DB_USER,DB_PASSWORD);     System.out.println("5");
         pc.addConnectionEventListener(this);
         System.out.println("6");
         Connection c = pc.getConnection();
         System.out.println("7");
         DatabaseMetaData metaData = c.getMetaData();
         System.out.println("8");
         System.out.println("Product name: "+ metaData.getDatabaseProductName());
         System.out.println("9");
         System.out.println("Product version: "+ metaData.getDatabaseProductVersion());
         System.out.println("Driver name: "+ metaData.getDriverName());
         System.out.println("Driver version: "+ metaData.getDriverVersion());
         c.close();
         try {
         java.lang.Thread.sleep(5000);
         } catch (InterruptedException ie) {
    public void connectionClosed(ConnectionEvent event) {
    System.out.println("connectionClosed method called.");
    public void connectionErrorOccurred(ConnectionEvent event) {
    System.out.println("connectionErrorOccurred method called.");
    Bolded code is giving problem..
    thanks in advance

    Hi All,
    I have got a solution for the posted problem. actually the missing code is
    db2ConnectionPoolDataSource.setPortNumber(50000);
    eventhough the default port of DB2 server is 50000, we have to mention it explicitly. otherwise it'll try to load the DLL file and if there is any problem loading the dll, it'll give the above said exception.
    thanks to all those who tried to bring the solution.

  • Java.lang.UnsatisfiedLinkError: no msawt in shared library path

    I am using IE5.5 on Windows 98SE, and every time I try to run an applet, I get the error "java.lang.UnsatisfiedLinkError: no msawt in shared library path" I have installed the JDK/JRE, but it has not done anything. I discovered that I was missing msawt.dll from my windows/system folder, but when I got it, it had no effect on the error message. I have gotten the same applets to run on other win98/IE5.5 machines. I read of this same problem in a linux forum somewhere, but nobody had a solution. What should I do? Thanks.

    Well, as tacky as it is to reply with the solution to my own problem, I found that installing a newer version of Microsoft's Java Virtual Machine, free from Microsoft's site, helped elminate that error. Perhaps this will help someone else.

  • Java.lang.UnsatisfiedLinkError: com.sun.media.vfw.VFWCapture.cacheFieldIDs()Z

    So i am trying to get started with the java media framework (JMF). Ive installed the jmf 2.1.1e for windows and i am using eclipse IDE.
    I have tried to add the jar files to the projects build path and dll files to the library path, but i get this error when trying to execute the project:
    java.lang.UnsatisfiedLinkError: com.sun.media.vfw.VFWCapture.cacheFieldIDs()Z
    Here is full log details:
    CaptureDeviceInfo: vfw:Microsoft WDM Image Capture (Win32):0 : vfw://0
    YUV Video Format: Size = java.awt.Dimension[width=640,height=480] MaxDataLength = 614400 DataType = class [B yuvType = 32 StrideY = 1280 StrideUV = 1280 OffsetY = 0 OffsetU = 1 OffsetV = 3
    YUV Video Format: Size = java.awt.Dimension[width=160,height=120] MaxDataLength = 38400 DataType = class [B yuvType = 32 StrideY = 320 StrideUV = 320 OffsetY = 0 OffsetU = 1 OffsetV = 3
    YUV Video Format: Size = java.awt.Dimension[width=320,height=240] MaxDataLength = 153600 DataType = class [B yuvType = 32 StrideY = 640 StrideUV = 640 OffsetY = 0 OffsetU = 1 OffsetV = 3
    Exception in thread "VFW Request Thread" java.lang.UnsatisfiedLinkError: com.sun.media.vfw.VFWCapture.cacheFieldIDs()Z
        at com.sun.media.vfw.VFWCapture.cacheFieldIDs(Native Method)
        at com.sun.media.vfw.VFWCapture.<clinit>(VFWCapture.java:27)
        at com.sun.media.protocol.vfw.VFWSourceStream.doConnect(VFWSourceStream.java:249)
        at com.sun.media.protocol.vfw.VFWSourceStream.run(VFWSourceStream.java:771)
        at java.lang.Thread.run(Thread.java:619)
    Can anyone help me ?
    消息编辑者为:68202d7a-8cea-4b67-88ff-d01edd8c7c1a

    Probably the libLinuxSerialParallel.so was not found.
    I copied this file to $JAVA_HOME/lib/i386 and it worked.

  • Java.lang.UnsatisfiedLinkError: no OCFPCSC1 ....

    Hi everyone,
    I'm trying to make Opencard work.I use a SCR335 USB Smart Card Reader(Microsystems) in WInXP SP2.
    I'm trying to execute the InsertCard demo sample. My opencard.properties file(which is located in C:\ocf\OCF1.2\components\sb-demo\src\demos\samples) containts the following lines:
    OpenCard.services = opencard.opt.util.PassThruCardServiceFactory
    OpenCard.terminals=com.ibm.opencard.terminal.pcsc10.Pcsc10CardTerminalFactoryWhen I run java demos.samples.InsertCard for the first time I got the following:
    java.lang.UnsatisfiedLinkError: no OCFPCSC1 in java.library.pathThen I followed DurangoVa's advice from http://forum.java.sun.com/thread.jspa?forumID=23&threadID=269402 and I dropped OCFPCSC1.DLL into my System32 directory.
    Then, tried again and I got the following:
    start use case: notification after card insertion
    please insert a card now!
    card was inserted
    finished use case: notification after card insertion
    ------------------------------------------------------------but my card is in my hands!!Which means not inserted!However the program says that some card was inserted..
    Does anybody knows what's wrong?
    In case this will help:
    When I execute java demos.samples.GetCardIDI get the following:
    start use case: get a card ID
    CardTerminalException:
    Pcsc10CardTerminal: PCSC Exception in method SCardGetStatusChange: error executing SCardGetStatusChange
    return code = 8010002e
    finished use case: get a card ID
    ------------------------------------------------------------

    I finaly found the solution to my problem in
    http://www.mail-archive.com/[email protected]/msg01715.html
    There were two drivers for card readers installed in the system but only one reader was connected...

  • LoadLibrary - java.lang.UnsatisfiedLinkError

    Hello,
    where does java search (c++)shared libraries by using loadLibrary?
    If I start my jar - I get the error:
    java.lang.UnsatisfiedLinkError: no lib in java.library.path
    at java.lang.ClassLoader.loadLibrary
    Thanks Sylvi

    I tryed both of you proposals. But my Error doesn't change.
    Message was edited by:
    Sylvi_hasi

  • [Help] Another java.lang.UnsatisfiedLinkError: no ocijdbc9

    Hi All,
    I just learnt how about Oracle. Then, now I need to use JDBC driver.
    I am using Oracle 8i.
    I tried to follow the instruction in here.
    http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/htdocs/jdbc817.html
    Then, I tried the basic sample provided there.
    But that give me the following error.
    Exception in thread "main" java.lang.UnsatisfiedLinkError: no ocijdbc9 in java.l
    ibrary.path
    at java.lang.ClassLoader.loadLibrary(Unknown Source)
    at java.lang.Runtime.loadLibrary0(Unknown Source)
    at java.lang.System.loadLibrary(Unknown Source)
    at oracle.jdbc.oci8.OCIDBAccess.logon(OCIDBAccess.java:300)
    at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:361)
    at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.ja
    va:485)
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:337)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at JdbcCheckup.main(JdbcCheckup.java:42)
    Can anybody tell me why? what's wrong with it?
    Moreover, I am wondering why it says no ocijdbc9, while I am using Oracle 8i.
    Could anybody explain please ...

    I suspect that you are using the oracle oci driver. That driver requires a n Oracle client installation on the machine which would be establishing connection. Moer specifically, it makes use of the native library ocijdbc9.dll and the directory containing it [if the installation has been done] should be present in the Path in environment variables.

  • HELP: java.lang.UnsatisfiedLinkError: no ... in java.library.path

    am the beginner of JNI. I write a test program to use C code in JAVA.
    [yxz155@lionxo JAVAaC]$ ls
    AClassWithNativeMethods.java theNativeMethod.c
    [yxz155@lionxo JAVAaC]$ javac AClassWithNativeMethods.java
    [yxz155@lionxo JAVAaC]$ javah -jni AClassWithNativeMethods
    [yxz155@lionxo JAVAaC]$ ls
    AClassWithNativeMethods.class AClassWithNativeMethods.java
    AClassWithNativeMethods.h theNativeMethod.c
    [yxz155@lionxo JAVAaC]$ gcc -c -fPIC -I/usr/global/java/include -I/usr/global/java/include/linux theNativeMethod.c
    [yxz155@lionxo JAVAaC]$ ls
    AClassWithNativeMethods.class AClassWithNativeMethods.java theNativeMethod.o
    AClassWithNativeMethods.h theNativeMethod.c
    [yxz155@lionxo JAVAaC]$ ld -G theNativeMethod.o -o libJCI.so -lm -lc -lpthread
    [yxz155@lionxo JAVAaC]$ ls
    AClassWithNativeMethods.class AClassWithNativeMethods.java theNativeMethod.c
    AClassWithNativeMethods.h libJCI.so theNativeMethod.o
    [yxz155@lionxo JAVAaC]$ java AClassWithNativeMethods
    Exception in thread "main" java.lang.UnsatisfiedLinkError: no CJI in java.library.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1682)
    at java.lang.Runtime.loadLibrary0(Runtime.java:822)
    at java.lang.System.loadLibrary(System.java:992)
    at AClassWithNativeMethods.<clinit>(AClassWithNativeMethods.java:9)
    [yxz155@lionxo JAVAaC]$
    The codes are as follows, I tried setProperty() as in java program, but it did not work. I also tried set LD_LIBRARY_PATH and it did not work either.
    //AClassWithNativeMethods.java
    import java.io.File;
    import java.lang.System;
    public class AClassWithNativeMethods{
    public native void theNativeMethod();
    static {
    //System.setProperty("java.library.path",System.getProperty("java.library.path")+ File.pathSeparator+"/home2/yxz155/JAVAaC");
    //System.out.println(System.getProperty("java.library.path"));
    System.loadLibrary("CJI");
    public static void main(String[] args){
    AClassWithNativeMethods test = new AClassWithNativeMethods ();
    test.theNativeMethod();
    // theNativeMethod.c
    #include <stdio.h>
    #include "AClassWithNativeMethods.h"
    JNIEXPORT void JNICALL Java_AClassWithNativeMethods_theNativeMethod
    (JNIEnv *env, jobject obj){
    printf("Hello~~~~");
    //AClassWithNativeMethods.h
    /* DO NOT EDIT THIS FILE - it is machine generated */
    #include <jni.h>
    /* Header for class AClassWithNativeMethods */
    #ifndef IncludedAClassWithNativeMethods
    #define IncludedAClassWithNativeMethods
    #ifdef __cplusplus
    extern "C" {
    #endif
    * Class: AClassWithNativeMethods
    * Method: theNativeMethod
    * Signature: ()V
    JNIEXPORT void JNICALL Java_AClassWithNativeMethods_theNativeMethod
    (JNIEnv *, jobject);
    #ifdef __cplusplus
    #endif
    #endif

    Hi all,
    I am getting the error in jdk 5:
    Exception in thread "main" java.lang.UnsatisfiedLinkError: getObjectSize0
    at sun.instrument.InstrumentationImpl.getObjectSize0(Native Method)
    at sun.instrument.InstrumentationImpl.getObjectSize(InstrumentationImpl.java:97)
    at ObjectSizeEstimator.main(ObjectSizeEstimator.java:25)
    while executing the following code:
    public class ObjectSizeEstimator {
    static {
    System.loadLibrary("instrument");
    public static void main(String[] args) throws Exception {
    Constructor ctor = InstrumentationImpl.class
    .getDeclaredConstructor(new Class[] { long.class, boolean.class });
    ctor.setAccessible(true);
    Instrumentation inst = (Instrumentation) ctor.newInstance(new Object[] {
    Long.valueOf(0L), Boolean.TRUE });
    System.out.println(inst.getObjectSize(new Object()));
    "getObjectSize0" is the native method. All of my classpath setting is in place. Can Anybody tell me why i am getting this error.
    Thanks in advance....:)

  • How do i solve the Runtime Error: java.lang.UnsatisfiedLinkError

    Runtime Error: java.lang.UnsatisfiedLinkError
    // Dialog_age
    import javax.swing.JOptionPane;
    public class Dialog_age
    public static void main(String arguments[])
    String Input_Age;
    int age;
    Input_Age = JOptionPane.showInputDialog("Enter a number.");
    age = Integer.parseInt(Input_Age);
    JOptionPane.showMessageDialog(null , "Your age is " + age);
    System.exit(0);
    }Whenever i run this program or a program similar to that program. I get the Runtime Error (anytime i run the program on a command prompt, but if i run it on my jGRASP it runs ok!): java.lang.UnsatisfiedLinkError.
    Here is my Error Message:
    C:\java>java Dialog_age
    Exception in thread "main" java.lang.UnsatisfiedLinkError: sun.font.FontManager.initIDs(
    Z)V
    at sun.font.FontManager.initIDs(Native Method)
    at sun.font.FontManager.access$000(Unknown Source)
    at sun.font.FontManager$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.font.FontManager.<clinit>(Unknown Source)
    at sun.java2d.SunGraphicsEnvironment.addDirFonts(Unknown Source)
    at sun.java2d.SunGraphicsEnvironment.registerFontsInDir(Unknown Source)
    at sun.java2d.SunGraphicsEnvironment.access$200(Unknown Source)
    at sun.java2d.SunGraphicsEnvironment$2.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.java2d.SunGraphicsEnvironment.<init>(Unknown Source)
    at sun.awt.Win32GraphicsEnvironment.<init>(Unknown Source)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at java.lang.Class.newInstance0(Unknown Source)
    at java.lang.Class.newInstance(Unknown Source)
    at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(Unknown Source)
    at javax.swing.RepaintManager.<clinit>(Unknown Source)
    at javax.swing.UIManager.initialize(Unknown Source)
    at javax.swing.UIManager.maybeInitialize(Unknown Source)
    at javax.swing.UIManager.getDefaults(Unknown Source)
    at javax.swing.UIManager.getString(Unknown Source)
    at javax.swing.UIManager.getString(Unknown Source)
    at javax.swing.JOptionPane.showInputDialog(Unknown Source)
    at javax.swing.JOptionPane.showInputDialog(Unknown Source)
    at Dialog_age.main(Dialog_age.java:14)
    But a few weeks ago i could run the program on a command prompt , perfectly!
    I recently came to the conclusion that it has something to do with me upgrading my IDE(jGRASP) and Java language.
    Now, since thats the case how do i resolve this error. That BUGGING the heck out of me!
    Thanks and Peace!

    Hi,
    Check which JRE/JDK is used by your jGRASP.Then set the path environment variables according to that.
    I'm afraid you have multiple jre/jdk in your system and one of that has problem with native libraries.
    Best of luck!!

  • HANA Studio installation error: Error getting the version of the native layer: java.lang.UnsatisfiedLinkError: no sapjco3 in java.library.path

    When attempting to add the ADT to HANA Studio I get the error:
    Error getting the version of the native layer: java.lang.UnsatisfiedLinkError: no sapjco3 in java.library.path
    Additionally I get something about a possibly missing Microsoft Runtime DLL VS2010.
    When I then attempt to add ABAP Projects I get the error:
    An error has occurred. See error log for more details.
    com/sap/mw/jco3/eclipse/Registry
    I have tried with sites:
    SAP Development Tools for Eclipse - Juno Software Repository
    SAP Development Tools for Eclipse - Kepler Software Repository
    I have been able to install the ADT on Eclipse-Kepler which is running fine.

    I did and on that page the following is stated:
    For Windows OS: DLLs VS2010 for communication with the back-end system is required.
    NOTE: Install either the x86 or the x64 variant, accordingly to your 32- or 64-Bit Eclipse installation.
    This seems exactly to address the issue I am grapling with, but when downloading and trying to install the file I get the message that the current version on my frontend is more recent than the version I am trying to install.
    Is that not strange?

  • Help regarding java.lang.UnsatisfiedLinkError

    Hi everyone ,
    I have a doubt regarding native property. I am using eclipse I wrote a program (inputoutput.java) to clear the screen after printing a line. This program creates an object (�console�) of �test� class and calls �clear� method. The test class loads the �ClearFunc.dll� file. I placed the ClearFunc.dll file along with the other class files. When I execute it is giving the following error.
    Exception in thread "main" java.lang.UnsatisfiedLinkError: no ClearFunc.dll in java.library.path
    at java.lang.ClassLoader.loadLibrary(Unknown Source)
    at java.lang.Runtime.loadLibrary0(Unknown Source)
    at java.lang.System.loadLibrary(Unknown Source)
    at inputoutput.test.<clinit>(test.java:15)
    at inputoutput.Printing.printing(inputoutput.java:22)
    at inputoutput.inputoutput.main(inputoutput.java:51)
    �test.java code�
    package inputoutput;
    public class test {
    //static final String path ="D:/java_workspace/input_output/bin/inputoutput/ClearFunc";
    public native void clear();
    /*public static void main(String[] args) {
    new test().clear();
    static {
    try{
    System.out.println("hi");
    System.loadLibrary("ClearFunc.dll");
    System.out.println("hello");
    catch(Exception e)
    System.out.println(e.toString()+"santhu");
    e.printStackTrace();
    "inputoutput.java code"/**
    package inputoutput;
    import java.io.*;
    * @author Santhosh_Thadvai
    class Printing implements Runnable{
         Thread t;
         public void run(){
         public void printing()throws IOException,FileNotFoundException {
              try{
                   test console = new test();
                   t=new Thread();
              t.start();
              FileInputStream fileinputstream = new FileInputStream("out.txt");
              int value = fileinputstream.read();
              while(value!=-1){
                   System.out.print((char)value);
                   Thread.sleep(50);
                   value=fileinputstream.read();
                   if((char)value=='\n')
                        console.clear();
              fileinputstream.close();
              catch(InterruptedException e){
                   System.out.println(e);
    public class inputoutput {
         * @param args
         public static void main(String[] args) throws IOException {
              Printing b=new Printing();
              b.printing();
    }

    plz, surround your code with : [code ] [ /code ]

Maybe you are looking for