0

我正在尝试在我的 Windows 7 系统上编译 JNativeHook 源代码。通过ant all在根文件夹中给出命令,我收到以下错误:

C:\Users\Nrusingh\Downloads\jnativehook-master (1)\jnativehook-master>ant all
Buildfile: C:\Users\Nrusingh\Downloads\jnativehook-master (1)\jnativehook-master\build.xml
init:
 [echo] Initializing local build environment...
 [echo] Project:            jnativehook 2.1.20170317
 [echo] Debug:              false
 [echo] Java Compiler:      modern
 [echo] Java Source:        1.8
 [echo] Java Target:        1.8
 [echo] Java Include:       C:\Program Files\Java\jdk1.8.0_102/include
 [echo] Java Args:
 [echo] Native Lib:         JNativeHook.dll
 [echo] Native OS:          windows
 [echo] Native Arch:        x86_64
 [echo] Native Toolchain:   gcc
 [echo] Native CFLAGS:      -O2 -pipe
 [echo] Native LDFLAGS:
[propertyfile] Creating new property file: C:\Users\Nrusingh\Downloads\jnativehook-master (1)\jnativehook-master\build.properties

compile-java:
 [echo] Compiling Java source...
[mkdir] Created dir: C:\Users\Nrusingh\Downloads\jnativehook-master (1)\jnativehook-master\bin\class\java
[javac] Compiling 27 source files to C:\Users\Nrusingh\Downloads\jnativehook-master (1)\jnativehook-master\bin\class\java
[javac] C:\Users\Nrusingh\Downloads\jnativehook-master (1)\jnativehook-master\src\java\org\jnativehook\AbstractSwingInputAdapter.java
[javac] C:\Users\Nrusingh\Downloads\jnativehook-master (1)\jnativehook-master\src\java\org\jnativehook\DefaultLibraryLocator.java
[javac] C:\Users\Nrusingh\Downloads\jnativehook-master (1)\jnativehook-master\src\java\org\jnativehook\GlobalScreen.java
[javac] C:\Users\Nrusingh\Downloads\jnativehook-master (1)\jnativehook-master\src\java\org\jnativehook\NativeHookException.java
[javac] C:\Users\Nrusingh\Downloads\jnativehook-master (1)\jnativehook-master\src\java\org\jnativehook\NativeInputEvent.java
[javac] C:\Users\Nrusingh\Downloads\jnativehook-master (1)\jnativehook-master\src\java\org\jnativehook\NativeLibraryLocator.java
[javac] C:\Users\Nrusingh\Downloads\jnativehook-master (1)\jnativehook-master\src\java\org\jnativehook\NativeMonitorInfo.java
[javac] C:\Users\Nrusingh\Downloads\jnativehook-master (1)\jnativehook-master\src\java\org\jnativehook\NativeSystem.java
[javac] C:\Users\Nrusingh\Downloads\jnativehook-master (1)\jnativehook-master\src\java\org\jnativehook\dispatcher\DefaultDispatchService.java
[javac] C:\Users\Nrusingh\Downloads\jnativehook-master (1)\jnativehook-master\src\java\org\jnativehook\dispatcher\SwingDispatchService.java
[javac] C:\Users\Nrusingh\Downloads\jnativehook-master (1)\jnativehook-master\src\java\org\jnativehook\example\NativeHookDemo.java
[javac] C:\Users\Nrusingh\Downloads\jnativehook-master (1)\jnativehook-master\src\java\org\jnativehook\keyboard\NativeKeyAdapter.java
[javac] C:\Users\Nrusingh\Downloads\jnativehook-master (1)\jnativehook-master\src\java\org\jnativehook\keyboard\NativeKeyEvent.java
[javac] C:\Users\Nrusingh\Downloads\jnativehook-master (1)\jnativehook-master\src\java\org\jnativehook\keyboard\NativeKeyListener.java
[javac] C:\Users\Nrusingh\Downloads\jnativehook-master (1)\jnativehook-master\src\java\org\jnativehook\keyboard\SwingKeyAdapter.java
[javac] C:\Users\Nrusingh\Downloads\jnativehook-master (1)\jnativehook-master\src\java\org\jnativehook\mouse\NativeMouseAdapter.java
[javac] C:\Users\Nrusingh\Downloads\jnativehook-master (1)\jnativehook-master\src\java\org\jnativehook\mouse\NativeMouseEvent.java
[javac] C:\Users\Nrusingh\Downloads\jnativehook-master (1)\jnativehook-master\src\java\org\jnativehook\mouse\NativeMouseInputAdapter.java
[javac] C:\Users\Nrusingh\Downloads\jnativehook-master (1)\jnativehook-master\src\java\org\jnativehook\mouse\NativeMouseInputListener.java
[javac] C:\Users\Nrusingh\Downloads\jnativehook-master (1)\jnativehook-master\src\java\org\jnativehook\mouse\NativeMouseListener.java
[javac] C:\Users\Nrusingh\Downloads\jnativehook-master (1)\jnativehook-master\src\java\org\jnativehook\mouse\NativeMouseMotionAdapter.java
[javac] C:\Users\Nrusingh\Downloads\jnativehook-master (1)\jnativehook-master\src\java\org\jnativehook\mouse\NativeMouseMotionListener.java
[javac] C:\Users\Nrusingh\Downloads\jnativehook-master (1)\jnativehook-master\src\java\org\jnativehook\mouse\NativeMouseWheelAdapter.java
[javac] C:\Users\Nrusingh\Downloads\jnativehook-master (1)\jnativehook-master\src\java\org\jnativehook\mouse\NativeMouseWheelEvent.java
[javac] C:\Users\Nrusingh\Downloads\jnativehook-master (1)\jnativehook-master\src\java\org\jnativehook\mouse\NativeMouseWheelListener.java
[javac] C:\Users\Nrusingh\Downloads\jnativehook-master (1)\jnativehook-master\src\java\org\jnativehook\mouse\SwingMouseAdapter.java
[javac] C:\Users\Nrusingh\Downloads\jnativehook-master (1)\jnativehook-master\src\java\org\jnativehook\mouse\SwingMouseWheelAdapter.java

download-libuiohook:

bootstrap-libuiohook:
 [echo] Bootstrapping libUIOHook...
[autoreconf] autoreconf --verbose --force --install

BUILD FAILED
C:\Users\Nrusingh\Downloads\jnativehook-master (1)\jnativehook-master\build.xml:345:
Execute failed: java.io.IOException:
Cannot run program "sh" (in directory"C:\Users\Nrusingh\Downloads\jnativehook-master (1)\jnativehook-master\src\libuiohook"):
CreateProcess error=2, The system cannot find the file specified
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
    at java.lang.Runtime.exec(Runtime.java:620)
    at org.apache.tools.ant.taskdefs.launcher.Java13CommandLauncher.exec(Java13CommandLauncher.java:58)
    at org.apache.tools.ant.taskdefs.Execute.launch(Execute.java:426)
    at org.apache.tools.ant.taskdefs.Execute.execute(Execute.java:440)
    at org.apache.tools.ant.taskdefs.ExecTask.runExecute(ExecTask.java:629)
    at org.apache.tools.ant.taskdefs.ExecTask.runExec(ExecTask.java:670)
    at org.apache.tools.ant.taskdefs.ExecTask.execute(ExecTask.java:496)
    at org.jnitasks.autotools.AutoreconfTask.execute(AutoreconfTask.java:113)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
    at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.Target.execute(Target.java:435)
    at org.apache.tools.ant.Target.performTasks(Target.java:456)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1405)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1376)
    at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
    at org.apache.tools.ant.Main.runBuild(Main.java:857)
    at org.apache.tools.ant.Main.startAnt(Main.java:236)
    at org.apache.tools.ant.launch.Launcher.run(Launcher.java:287)
    at org.apache.tools.ant.launch.Launcher.main(Launcher.java:113)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
    at java.lang.ProcessImpl.create(Native Method)
    at java.lang.ProcessImpl.<init>(ProcessImpl.java:386)
    at java.lang.ProcessImpl.start(ProcessImpl.java:137)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
    ... 24 more

Total time: 6 seconds

任何人都可以通过建议正确的构建过程来帮助我构建它吗?

4

1 回答 1

0

错误有以下几点:

无法运行程序“sh”

“sh”是MSYS2提供的程序。在 Windows 上构建 JNativeHook 需要 MSYS2

我们将使用MSys2来编译 JNativeHook。

按照 JNativeHook 网站上的说明了解如何构建源代码。

于 2017-03-17T14:50:25.837 回答