Hi All,
Am working on a Java application in which I have to use the JNI to Interface with some native code for both windows and unix. Am using netbeans IDE with the C/C++ pack installed. Am also using Cygwin as my compiler (gcc), this is ostensibly because I hope this compiler will also compile the unix native libraries since I don't have a Linux installation. (I am working on a personal project from the office and can't get linux installed).
First question will it be possible to get native linux libs from Cygwin?
I tried doing a small test using the windows function FindWindow() and I am not able to build it. gcc complains about the jlong type defined by the JNI headers.
Here is the code followed by the netbeans output.
Help is greatly appreciated.
The Java class
-
-
public class OslibClass {
-
static{
-
System.loadLibrary("libOsibClass");
-
}
-
-
public void OslibClass(){
-
-
}
-
private static native long getWindowHandle();
-
-
}
-
Native code...
-
-
#include <OslibClass.h>
-
#include <windows.h>
-
-
-
JNIEXPORT jlong JNICALL Java_org_OslibClass_getWindowHandle
-
(JNIEnv *, jclass){
-
jlong handle;
-
HWND hwnd = FindWindow("SunAwtFrame","GetHandle - NetBeans IDE 6.1");
-
handle = hwnd;
-
return handle;
-
}
-
Netbeans Output...