UnsatisfiedLinkError...help!!!

Hi...i created a small java program. I import here com.mypackage; I copied this in java/lib and i included this .jar in my classpath. I can compile the program, but when i run it i get this errror:
Exception in thread "main" java.lang.UnsatisfiedLinkError : no mypackage in java.library.path.
Can anyone help me with this??? Please!
Thanks in advance

Did you do a call like: System.loadLibrary("mypackage") ??
Don't do that, because loadLibrary() is for loading system-dependend native libraries (for example DLLs in Windows).
Use this:
import com.mypackage.*;
Jesper

Similar Messages

  • Java.lang.UnsatisfiedLinkError: Help Sought.

    Hi,
    I have a DLL and i know the method signatures, which is:
    USB_STATUS USB_Initialize(short nWidth, short nHeight, HWND hWnd);
    USB_STATUS is of int type or probably it returns int type. It may be a struct also. I am not sure how it is defined as i just have API and dll.
    Equivalent native method signature in java, i wrote as:
    public native int USB_Initialize (short nWidth, short nHeight, long hWnd);
    HWND probably returns long/int type value.
    Created .h file using javah. The dll is in path and is loaded. But get above error when call USB_Initialize method.
    From this i can see there must be only one reason that my method signature in java probably does not comply or something similar.
    Any idea as how to over come this. Would appreciate if can tell what should be correct signature for the native method in java given the C++ method above.

    Calling native code from Java doesn't work that way. Java can't link directly with a regular native library, but only with a native library that comforms to the JNI specification. In this case you need a JNI wrapper library that you can call from Java and which will call your existing USB library.
    Start here: http://java.sun.com/docs/books/jni
    Especially: http://java.sun.com/docs/books/jni/html/stubs.html#27578
    -slj-

  • 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.

  • (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.

  • UnsatisfiedLinkError Problem.(Urgent)Pls Help!!

    Hi,
    I just want to run a swing under win98 OS platform and an error message appeared :
    Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\jdk1.4\jre\bin\awt.dll: An attempt was made to load a program with an incorrect format
    I have changed different version of JDK including 1.3.1 and 1.4beta, but the problem still exists.
    Is that any special setting need for running interface as I can run the java program in no trouble at all if there is no any interface.
    Another thing when i double click the java plug-in, there is an error message: "Could not found the main class. The Program would exit. ". How come?
    Pls Help and many thx.

    Post you code.

  • Plz help me to correct unsatisfiedlinkerror - on loading a library file

    Dear friends,
    I have to load a .dll file through System.loadLibrary() method. Dll file is stored in c:\<appname>\lib\sample.dll in server machine.when a client calls this java prgm,dll has to be loaded to client machine.JVM searches the dll file only in the directories which are specified in PATH env variable.
    Before calling System.loadLibray("libraryname"),I include my library path to PATH variable by the following way
    Process p=Runtime.getRuntime.exec("command.com /c set PATH=" + "\\\\<servername>\\c\\<appname>\\lib" + "%PATH%;") ;
    System.loadLibrary("libname");
    Unsatisfiedlinkerror no <libraryname> was found in java.library.path
    I also try to include my library path in java.library.path through System.setProperty() method. But the same error is arrised.
    The dll file is loaded only when, I include my library path in autoexec.bat file. But this is not the correct way.I have to set my library path through java program only. (os -Windows 98 in Both server and client)
    Plz help to solve this plm.

    Instead of setting path thru command come set path vis System.getProperty("path") then add ur path in return value. Set modified path again as System.setProperty("path", value). Try this solution.

  • 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..please help

    Hi...i created a small java program. I import here com.mypackage; I copied this in java/lib and i included this .jar in my classpath. I can compile the program, but when i run it i get this errror:
    Exception in thread "main" java.lang.UnsatisfiedLinkError : no mypackage in java.library.path.
    Can anyone help me with this??? Please!
    Thanks in advance

    Remove the line that says System.loadLibrary. It is used to load native code stored in e.g. .dll or .so files, it doesn't have anything to do with using class libraries written in Java and compiled to .class files. If you have your classpath set correctly or your jar file in the right place it is all done automatically for you.

  • 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....:)

  • 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 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 ]

  • [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 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.)

  • GifImageDecoder,  UnsatisfiedLinkError Exception

    Hello there
    I am getting the following exception during rendering pdf with fop and java. The stack trace is attached at the end of this message. It seems that the gif images could not be decoded because of a missing native library. The application is running on a sun solaris environment with JRE 1.3.1_04-b02.
    Does anyone know what could be missining ? I guess the GIF decoding is not part of the JVM and needs some additional *.so libraries ? If yes which ones ?
    Where is the java doc and source code for the class " sun.awt.image.GifImageDecoder" available ?
    Thank you for any hints.
    regards
    Mark
    java.lang.UnsatisfiedLinkError: exception occurred in JNI_OnLoad
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1414)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1330)
    at java.lang.Runtime.loadLibrary0(Runtime.java:744)
    at java.lang.System.loadLibrary(System.java:815)
    at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:48)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.awt.image.NativeLibLoader.loadLibraries(NativeLibLoader.java:36)
    at sun.awt.image.GifImageDecoder.<clinit>(GifImageDecoder.java:362)
    at sun.awt.image.InputStreamImageSource.getDecoder(InputStreamImageSource.java:217)
    at sun.awt.image.URLImageSource.getDecoder(URLImageSource.java:137)
    at sun.awt.image.InputStreamImageSource.doFetch(InputStreamImageSource.java:246)
    at sun.awt.image.ImageFetcher.fetchloop(ImageFetcher.java:167)
    at sun.awt.image.ImageFetcher.run(ImageFetcher.java:135)

    I think Sun doesn't guarantee the existence of any sun.* packages to be included in the JRE/JDK. Nevertheless, it might be true that only some library is missing, but I am sorry, I can't help.
    The Image I/O facility included with J2SE 1.4 might help, can you give it a try instead?
    Regards,
    Fritz

  • An old and difficult problem about "UnsatisfiedLinkError"

    Hi dear all,
    I have been struck with the problem about "UnsatisfiedLinkError". I have a c++ class HelloWorld with a method hello(), and I want to call it from within a java class. In fact, I have succeeded in calling it on the windows platform. But when I transfer it to linux, the error "UnsatisfiedLinkError" comes out. I have tried to take the measures as Forum has suggested, but it failed.
    The source code is very simple to demonstrate JNI.
    "HelloWorld.h"
    #ifndef INCLUDEDHELLOWORLD_H
    #define INCLUDEDHELLOWORLD_H
    class HelloWorld
    public:
    void hello();
    #endif
    "HelloWorld.cpp"
    #include <iostream>
    #include "HelloWorld.h"
    using namespace std;
    void HelloWorld::hello()
    cout << "Hello, World!" << endl;
    "JHelloWorld.java"
    public class JHelloWorld
    public native void hello();
    static
    System.loadLibrary("hellolib");
    public static void main(String[] argv)
    JHelloWorld hw = new JHelloWorld();
    hw.hello();
    "JHelloWorld.cpp"
    #include <iostream>
    #include <jni.h>
    #include "HelloWorld.h"
    #include "JHelloWorld.h"
    JNIEXPORT void JNICALL Java_JHelloWorld_hello (JNIEnv * env, jobject obj)
    HelloWorld hw;
    hw.hello();
    All the files are in the same directory and all the processes are under the dirctory:
    1. javac JHelloWorld.java
    2. javah -classpath . JHelloWorld
    3. g++ -c -I/usr/java/jdk1.3/include -I/usr/java/jdk1.3/include/linux JHelloWorld.cpp HelloWorld.cpp
    4. ld -shared -o hellolib.so *.o
    5. java -cp . -Djava.library.path=. JHelloWorld
    Exception in thread "main" java.lang.UnsatisfiedLinkError: no hellolib in java.library.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1349)
    at java.lang.Runtime.loadLibrary0(Runtime.java:749)
    at java.lang.System.loadLibrary(System.java:820)
    at JHelloWorld.<clinit>(JHelloWorld.java:7)
    Tried another measure:
    i) export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH
    ii)java -cp . JHelloWorld
    The same error came out as above.
    I really don't know what is wrong with it.
    Would you like to help me as soon as possible?
    Thanks.
    Regards,
    Johnson

    Hi Fabio,
    Thanks a lot for your help.
    It is very kind of you.
    Regards,
    Johnson

Maybe you are looking for