C++/Java - Keyboard Hook

728 Views Asked by At

I am attempting to create a keyboard hook to use in Java. After some research, I realized I will need some things from C++. I don't have much experience with C++, I have only messed with the syntax for a short while. How would I do this in C++? And how would I make the C++ code interact with the Java code? Any help is greatly appreciated.

1

There are 1 best solutions below

3
On BEST ANSWER

I'm not exactly sure what you want for your C++ code, but here's how you would make it work with Java:

Look into JNI, it'll explain how to execute native code through Java

http://java.sun.com/developer/onlineTraining/Programming/JDCBook/jni.html

Essentially, you use a tool to create glue headers that you include in your C++ application. The Java code will automatically call the native library when you call a native function.

Also keep in mind that there's a speed penalty for going from native to java layer.