Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Please help...Can't find dependent libraries.

843829Aug 9 2004 — edited Aug 10 2004
I've searched and read, and tried several things but every time I run my application I get this:
java.lang.UnsatisfiedLinkError: C:\JBuilderX\Projects\AlwaysOnTop\AlwaysOnTop.dll: Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1560)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1485)
at java.lang.Runtime.loadLibrary0(Runtime.java:788)
at java.lang.System.loadLibrary(System.java:834)
at alwaysontop.MainFrame.<clinit>(MainFrame.java:108)
at alwaysontop.AlwaysOnTopApp.<init>(AlwaysOnTopApp.java:22)
at alwaysontop.AlwaysOnTopApp.main(AlwaysOnTopApp.java:68)
Exception in thread "main"

Here is exactly what I did, maybe someone can spot what I did wong:

1) Created AlwaysOnTop like this:
package alwaysontop;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.event.*;

public class MainFrame extends JFrame
{
...
 static
  {
   System.loadLibrary("AlwaysOnTop");
   //Runtime.getRuntime().loadLibrary("AlwaysOnTop"); //Tried this too...same thing
  }

  public static native void setWindowAlwaysOnTop(String title, boolean flag);
...
2) I then built the application

3) I opened a command prompt and went to the classes directory just on top of alwaysontop directory. It looks like this:
C:\Projects\AlwaysOnTop\classes\alwaysontop

So, I was in the C:\Projects\AlwaysOnTop\classes level

3) Next I generated the header file like this:
javah -jni -classpath alwaysontop MainFrame

4) Copied MainFrame.h over to the CPP project area.

5) Created a C file (not a C++, tried that first, then tried C style after reading something that recomended it). This file looks like this:
#include "jni.h"
#include "MainFrame.h"
#include <stdio.h>
#include <windows.h>
#pragma argsused
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
        return 1;
}

JNIEXPORT void JNICALL Java_Win32Native_setWindowAlwaysOnTop(JNIEnv *env, jclass obj, jstring strWindowTitle, jboolean bAlwaysOnTop)
{
        HWND hwnd = NULL;
        const char *str = (*env)->GetStringUTFChars(strWindowTitle,0);
        hwnd = ::FindWindow(NULL,str);
        (*env)->ReleaseStringUTFChars(strWindowTitle,str);

        if (bAlwaysOnTop)
        {
          SetWindowPos((HWND) hwnd,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
        }
        else
        {
          SetWindowPos((HWND) hwnd,HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
        }

        return;
}
6) Copied the DLL that got generated to thw Windows\System32 directory.

7) Ran the application from JBuilder.

8) Got the error...banged head into wall for umteenth time.

Note that the java.library.path looks like this:

C:\JBuilderX\jdk1.4\bin;.;C:\WINDOWS\System32;C:\WINDOWS;C:\WINDOWS\SYSTEM32;C:\WINDOWS;C:\WINDOWS\SYSTEM32\WBEM;C:\DMI\WIN32\BIN;C:\Program Files\Microsoft SDK\Bin\.;C:\Program Files\Microsoft SDK\Bin\WinNT\.;C:\JavaSDKs\j2sdk1.4.2_01\bin;C:\Ant\bin; ...

So the C:\Windows\System32 is there!

What do I need to do for Java to be able to find the dependant libraries?

THANKS!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 7 2004
Added on Aug 9 2004
17 comments
1,850 views