I am using jnativehook on my program. I edit source code little and It works well on mac. But When it is executed on window, I got this error.
8월 18, 2017 10:47:48 오전 org.jnativehook.DefaultLibraryLocator getLibraries
심각: Unable to extract the nativelibrary /org/jnativehook/lib/windows/x86_64/JNativeHook.dll!
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.launcher.LauncherHelper$FXHelper.main(Unknown Source)
Caused by: java.lang.UnsatisfiedLinkError: org.jnativehook.GlobalScreen.getAutoRepeatRate()Ljava/lang/Integer;
at org.jnativehook.GlobalScreen.getAutoRepeatRate(Native Method)
at org.jnativehook.GlobalScreen.<clinit>(Unknown Source)
at SmiPlayer.Main.main(Main.java:75)
... 11 more
Exception running application SmiPlayer.Main
So I tried to build it on Window. I setted JAVA_HOME path and added JNITasks. But I got this message.
BUILD FAILED
C:\jnativehook-2.1.0\build.xml:345: Execute failed: java.io.IOException: Cannot run program "sh" (in directory "C:\jnativehook-2.1.0\src\libuiohook"): CreateProcess error=2
I tried cross.build.xml too but I god this error.
BUILD FAILED
C:\jnativehook-2.1.0\cross.build.xml:160: The following error occurred while executing this line:
C:\jnativehook-2.1.0\jnitasks\build.xml:76: Compile failed; see the compiler error output for details.
line 160 is 5th line of below code block Compiling JNITasks source...
<ant antfile="${basedir}/jnitasks/build.xml" dir="${basedir}/jnitasks">
<target name="compile" />
<target name="jar" />
<!-- We need to override the src and bin locations. -->
<property name="dir.bin" value="${basedir}/jnitasks/bin" />
<property name="dir.src" value="${basedir}/jnitasks/src" />
<property name="dir.jar" value="${basedir}" />
<!-- Set a few of the configurable properties. -->
<property name="ant.build.debug" value="${ant.build.debug}" />
<property name="ant.build.javac.compiler" value="${ant.build.javac.compiler}" />
<property name="ant.build.javac.source" value="${ant.build.javac.source}" />
<property name="ant.build.javac.target" value="${ant.build.javac.target}" />
<property name="ant.build.javac.args" value="${ant.build.javac.args}" />
</ant>
</target>
and line 76 is 8th line of below code block
<condition property="ant.build.javac.bootclasspath" value="${env.JDK_HOME}/bundle/Classes/classes.jar">
<available file="${env.JDK_HOME}/bundle/Classes/classes.jar" type="dir" />
</condition>
<condition property="ant.build.javac.bootclasspath" value="${env.JAVA_HOME}/bundle/Classes/classes.jar">
<available file="${env.JAVA_HOME}/bundle/Classes/classes.jar" type="dir" />
</condition>
<condition property="ant.build.javac.bootclasspath" value="${java.home}/bundle/Classes/classes.jar">
<available file="${java.home}/bundle/Classes/classes.jar" type="file" />
</condition>
<fail message="Could not determine ant.build.javac.bootclasspath location. Please set your JDK_HOME / JAVA_HOME environment variable or manually set the ant.build.javac.bootclasspath property to the location of your rt.jar file.">
I didn't tried cross.build.xml on mac yet.
I need some help..
You must compile all the native code separately for each platform. You cannot compile for Windows on mac without a cross compiler like msys2. You can compile a set of binaries on each platform using ant compile-native
and combine the lib directories before calling ant jar
. The cross.build.xml file is used to cross-compile all platforms from linux. Instructions on cross-compiling are also located in the Wiki.
Your Windows 10 build is failing because you are not using the correct shell to compile from. You must use the mingw32/64 shell to run ant. Again, this is all outlined in the Wiki on the project page.