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!

Unable to use JNI method

843829Feb 27 2010 — edited Mar 3 2010
my C++ function uses Windows Libraries... checking Code Blocks, i found out that the Linker uses gdi32.lib, user32.lib and kernel32.lib. the C++ application runs fine by itself (as an .exe).

anyway, when i didnt include the libraries in my CPP project for JNI, it compiles sucessfully. however, when i wanna use the method that does the JNI function, the application gives me the following Exception:

Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: GUI.RefreshDesktop.refreshDesktop()V

so, i thought i needed to include these libraries in my Java class as well.
class RefreshDesktop{
	static{
		System.load("libRefreshDesktopCPP.dll"); //don't worry about the pathing. :D
		System.load("Gdi32.Lib");
		System.load("User32.Lib");
		System.load("Kernel32.Lib");
	}

	public static void refresh(){
		new RefreshDesktop().refreshDesktop();
	}

	private native void refreshDesktop();
}
however, upon execution, i get the Exception:
Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: Gdi32.Lib: %1 is not a valid Win32 application

when i tried to link these libraries in the Linker in the C++ project, i get errors saying those files cannot be found, even though i used absolute path.


so, how do i make this stuff work?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 31 2010
Added on Feb 27 2010
22 comments
944 views