Compilation failure in JNativeHook

497 views Asked by At

Trying to compile this https://github.com/kwhat/jnativehook/wiki/Compiling

made it as far as the step where I have to run ant all to build.

Compile fails with the following in command prompt.

    [javac] Fatal Error: Unable to find package java.lang in classpath or bootcl
asspath

BUILD FAILED
C:\Users\George\Downloads\sounds\JNativeHook-2.0.1\JNativeHook\build.xml:394: Co
mpile failed; see the compiler error output for details.

Total time: 0 seconds

EDIT: I just copied the rt file into the directory i'm trying to compile. I got past the first error but now I'm getting

ava\org\jnativehook\mouse\NativeMouseWheelListener.java

download-libuiohook:

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

BUILD FAILED
C:\Users\George\Downloads\sounds\JNativeHook-2.0.1\JNativeHook\build.xml:351: Ex
ecute failed: java.io.IOException: Cannot run program "sh" (in directory "C:\Use
rs\George\Downloads\sounds\JNativeHook-2.0.1\JNativeHook\src\libuiohook"): Creat
eProcess 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(Jav
a13CommandLauncher.java:58)
        at org.apache.tools.ant.taskdefs.Execute.launch(Execute.java:428)
        at org.apache.tools.ant.taskdefs.Execute.execute(Execute.java:442)
        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(DelegatingMethodAcces
sorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.jav
a: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(DefaultExe
cutor.java:41)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
        at org.apache.tools.ant.Main.runBuild(Main.java:853)
        at org.apache.tools.ant.Main.startAnt(Main.java:235)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:285)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:112)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find th
e 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: 1 second

Still diligently trying to figure this out in the mean time.

Update:

I think I've been going about this wrong. I tried doing this inside MINGW64 which is probably how I should have been doing it.

Sadly still get an error I'm looking into.

compile-java:
     [echo] Compiling Java source...

download-libuiohook:

bootstrap-libuiohook:
     [echo] Bootstrapping libUIOHook...
[autoreconf] autoreconf --verbose --force --install
[autoreconf] autoreconf: Entering directory `.'
[autoreconf] autoreconf: configure.ac: not using Gettext
[autoreconf] autoreconf: running: aclocal --force -I m4
[autoreconf] aclocal-1.15: error: aclocal: file '/msys64/usr/share/aclocal/xsize                    .m4' does not exist
[autoreconf] autoreconf: aclocal failed with exit status: 1

BUILD FAILED
C:\Users\George\Downloads\sounds\JNativeHook-2.0.1\JNativeHook\build.xml:351: ex                    ec returned: 1

Total time: 2 seconds

UPDATE:

Wow so how many shells does msys64 have. I've now tried what seems to be the last and final shell msys2_shell.bat and its gotten even further but still fails.

Now I get

JNativeHook/bin --enable-debug --enable-quiet --enable-static --disable-shared --with-pic
[configure] checking build system type... x86_64-pc-msys
[configure] checking host system type... x86_64-pc-msys
[configure] checking target system type... x86_64-pc-msys
[configure] checking for a BSD-compatible install... /usr/bin/install -c
[configure] checking whether build environment is sane... yes
[configure] checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
[configure] checking for gawk... gawk
[configure] checking whether make sets $(MAKE)... yes
[configure] checking whether make supports nested variables... yes
[configure] checking for style of include used by make... GNU
[configure] checking for gcc... clang
[configure] configure: error: in `/c/Users/George/Downloads/sounds/JNativeHook-2.0.1/JNativeHook/bin/libuiohook':
[configure] checking whether the C compiler works... no
[configure] configure: error: C compiler cannot create executables
[configure] See `config.log' for more details

BUILD FAILED
C:\Users\George\Downloads\sounds\JNativeHook-2.0.1\JNativeHook\build.xml:361: exec returned: 77

Total time: 37 seconds

So close.

UPDATE:

Installed clang and now get this detailed error from the config.log file.

configure:3580: checking whether the C compiler works
configure:3602: clang -march=armv6j -mfpu=vfp -mfloat-abi=hard -Os -g -pipe -fomit-frame-pointer -flto -ffat-lto-objects -fno-stack-protector  -Wl,--as-needed,-O1 -flto conftest.c  >&5
clang.exe: warning: optimization flag '-ffat-lto-objects' is not supported
clang.exe: error: 'i686-pc-windows-gnu': unable to pass LLVM bit-code files to linker
configure:3606: $? = 1
configure:3644: result: no
configure: failed program was

:

2

There are 2 answers

0
Nonlin On

Ok so for future JNativeHook compiler noobies like myself doing this on windows 8.1 here is what I had to do to get this working.

Aside from following all the steps in the compile for windows section provided on their git.

You also need to...

Download LLVM for windows. Copy your rt.jar into the JNativeHook directory. And make sure absolutely make sure that you've deleted any build.properties generated from failed builds.

That should get it working.

0
Alex Barker On

Dont forget to run ant distclean first if you are trying to compile 2.0.1. I botched the package process by forgetting to include the build.properties file in the exclude list for the zip file. I think that will also fix your rt.jar copying issue. It may solve all of your issues ;) Anyway, 2.0.2 will fix the problem and is scheduled for release on Sunday.