0

I am on MacOS and am having a problem that has been asked before on here numerous times. After several hours of trying all solutions, I am unable to get this error

fatal error: 'jni.h' file not found

to go away. I included in the file I am trying to compile

#include <jni.h>

and my makefile has my JAVA_HOME set to $JAVA_HOME

JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-16.jdk/Contents/Home
CHuck
  • 11
  • 2
  • 1
    The value of the `JAVA_HOME ` environment variable is completely irrelevant for how the c++ compiler is looking up the path where `jni.h` should be found. Show us a [mcve], especially of how the c++ code is built. – πάντα ῥεῖ Apr 06 '21 at 17:15

1 Answers1

0

You have to make sure to properly configure build environment.

Take a look here to learn how to build simple JNI based code in macOS

https://github.com/mkowsiak/jnicookbook/tree/master/recipes/recipeNo001

In general, what you want to have is setting -I during compilation

-I${JAVA_HOME}/include -I${JAVA_HOME}/include/darwin

You can also use Xcode to build library: https://www.youtube.com/watch?v=WEA-3uI7Y18

Oo.oO
  • 12,464
  • 3
  • 23
  • 45