I'm getting this error in my Mac, Java 11.
I've gone through all the similar questions in stack overflow. They suggest to set JAVA_HOME properly. I think I have configured properly and ensured jni.h is present in the directory.
My environment variables
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-11.0.3.jdk/Contents/Home
PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Users/selvakumar/apache-maven-3.5.2/bin:/Library/Java/JavaVirtualMachines/jdk-11.0.3.jdk/Contents/Home/bin:/Library/Java/JavaVirtualMachines/jdk-11.0.3.jdk/Contents/Home/include
Complete ERROR
apples-MacBook-Pro:wrapper-java selvakumar$ cmake --build ./build/cmake --target quickjs-java-wrapper -j 6
[1/3] Building CXX object CMakeFiles/quickjs-java-wrapper.dir/Users/selvakumar/newworkspace/quickjs-wrapper/native/cpp/quickjs_context_jni.cpp.o
FAILED: CMakeFiles/quickjs-java-wrapper.dir/Users/selvakumar/newworkspace/quickjs-wrapper/native/cpp/quickjs_context_jni.cpp.o
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -DCONFIG_BIGNUM -DCONFIG_VERSION=\"2021-03-27\" -Dquickjs_java_wrapper_EXPORTS -I/include -I/include/darwin -g -std=gnu++11 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk -fPIC -MD -MT CMakeFiles/quickjs-java-wrapper.dir/Users/selvakumar/newworkspace/quickjs-wrapper/native/cpp/quickjs_context_jni.cpp.o -MF CMakeFiles/quickjs-java-wrapper.dir/Users/selvakumar/newworkspace/quickjs-wrapper/native/cpp/quickjs_context_jni.cpp.o.d -o CMakeFiles/quickjs-java-wrapper.dir/Users/selvakumar/newworkspace/quickjs-wrapper/native/cpp/quickjs_context_jni.cpp.o -c /Users/selvakumar/newworkspace/quickjs-wrapper/native/cpp/quickjs_context_jni.cpp
/Users/selvakumar/newworkspace/quickjs-wrapper/native/cpp/quickjs_context_jni.cpp:1:10: fatal error: 'jni.h' file not found
#include <jni.h>
^~~~~~~
1 error generated.
[2/3] Building CXX object CMakeFiles/quickjs-java-wrapper.dir/Users/selvakumar/newworkspace/quickjs-wrapper/native/cpp/quickjs_wrapper.cpp.o
FAILED: CMakeFiles/quickjs-java-wrapper.dir/Users/selvakumar/newworkspace/quickjs-wrapper/native/cpp/quickjs_wrapper.cpp.o
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -DCONFIG_BIGNUM -DCONFIG_VERSION=\"2021-03-27\" -Dquickjs_java_wrapper_EXPORTS -I/include -I/include/darwin -g -std=gnu++11 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk -fPIC -MD -MT CMakeFiles/quickjs-java-wrapper.dir/Users/selvakumar/newworkspace/quickjs-wrapper/native/cpp/quickjs_wrapper.cpp.o -MF CMakeFiles/quickjs-java-wrapper.dir/Users/selvakumar/newworkspace/quickjs-wrapper/native/cpp/quickjs_wrapper.cpp.o.d -o CMakeFiles/quickjs-java-wrapper.dir/Users/selvakumar/newworkspace/quickjs-wrapper/native/cpp/quickjs_wrapper.cpp.o -c /Users/selvakumar/newworkspace/quickjs-wrapper/native/cpp/quickjs_wrapper.cpp
In file included from /Users/selvakumar/newworkspace/quickjs-wrapper/native/cpp/quickjs_wrapper.cpp:4:
/Users/selvakumar/newworkspace/quickjs-wrapper/native/cpp/quickjs_wrapper.h:15:10: fatal error: 'jni.h' file not found
#include <jni.h>
^~~~~~~
1 error generated.
ninja: build stopped: subcommand failed.
Still getting the error. I'm not sure what am I missing here.
Background:
I'm trying to use quickjs in java using https://github.com/HarlonWang/quickjs-wrapper. Getting this error while running the command cmake --build ./build/cmake --target quickjs-java-wrapper -j 6
Please note that Nashorn is deprecated. Therefore I didn't use it.
The error in your edit proves that the JAVA_HOME
environment variable was not set when you ran cmake
to generate the build system.
Just to be sure, nuke your build directory and run cmake
again with the environment variable present:
$ rm -rf build/cmake
$ export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-11.0.3.jdk/Contents/Home
$ cmake -B build/cmake .
$ cmake --build build/cmake --target quickjs-java-wrapper -j 6