我在我的程序上使用 jnativehook。我很少编辑源代码,它在 mac 上运行良好。但是当它在窗口上执行时,我得到了这个错误。
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
所以我尝试在Window上构建它。我设置了 JAVA_HOME 路径并添加了 JNITasks。但我收到了这条信息。
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
我也尝试过 cross.build.xml,但我上帝这个错误。
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.
第 160 行是下面代码块的第 5 行正在编译 JNITasks 源...
<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>
第 76 行是下面代码块的第 8 行
<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.">
我还没有在mac上尝试过cross.build.xml。
我需要一些帮助..