estou executando o codigo abaixo no eclipse juno com java 1.6.37 e windows 7 ultimate
import org.jnativehook.GlobalScreen;
import org.jnativehook.NativeHookException;
import org.jnativehook.keyboard.NativeKeyEvent;
import org.jnativehook.keyboard.NativeKeyListener;
public class GlobalKeyListenerExample implements NativeKeyListener {
public void nativeKeyPressed(NativeKeyEvent e) {
System.out.println("Key Pressed: " + NativeKeyEvent.getKeyText(e.getKeyCode()));
if (e.getKeyCode() == NativeKeyEvent.VK_ESCAPE) {
GlobalScreen.unregisterNativeHook();
}
}
public void nativeKeyReleased(NativeKeyEvent e) {
System.out.println("Key Released: " + NativeKeyEvent.getKeyText(e.getKeyCode()));
}
public void nativeKeyTyped(NativeKeyEvent e) {
System.out.println("Key Typed: " + e.getKeyText(e.getKeyCode()));
}
public static void main(String[] args) {
try {
GlobalScreen.registerNativeHook();
}
catch (NativeHookException ex) {
System.err.println("There was a problem registering the native hook.");
System.err.println(ex.getMessage());
System.exit(1);
}
//Construct the example object and initialze native hook.
GlobalScreen.getInstance().addNativeKeyListener(new GlobalKeyListenerExample());
}
}
se eu rodar o projeto no eclipse, o codigo funciona sem erros
se eu gerar um jara executavel com o FATJAR e One-JAR obtenho o seguinte erro:
JarClassLoader: Warning: Unable to load native library: java.lang.NullPointerExc
eption
Exception in thread "Thread-0" java.lang.NoClassDefFoundError: Failed to locate
the org.jnativehook.mouse.NativeMouseWheelEvent class
There was a problem registering the native hook.
Failed to create JNI global references
alguem pode me ajudar a resolver ?