1

I've tried to run an old java program with some libraries in C. While running make command,I kept encounter this error which I believe is related to JAVA_HOME setting

swig/main_6_comp_wrap.c:154:10: 

fatal error: jni.h: No such file or directory
#include <jni.h>
          ^~~~~~~

After several attempts of installation with JDK, swig, and gcc with Homebrew, it didn't work out. I am pretty sure jni.h file is located in include folder of JAVA_HOME.

JAVA_HOME   = /Library/Java/JavaVirtualMachines/jdk1.8.0_261.jdk/Contents/Home/
JDK_HOME    = $(JAVA_HOME)
JRE_HOME    = $(JAVA_HOME)

SWIG        = swig
CC          = gcc
CFLAGS          = -O2 -fno-strict-aliasing -Wall -fno-common \
          -I/System/Library/Frameworks/JavaVM.framework/Headers/
BUILDLIB    = gcc -shared
LIB6        = java/classes/libC6_comp_backend.jnilib
LIB21       = java/classes/libC21_comp_backend.jnilib

System: MacOS Catalina 10.15.7 swig: 3.0.12 gcc: 10.2.0

EEEEEric
  • 77
  • 3
  • 9

1 Answers1

2

You need to replace -I/System/Library/Frameworks/JavaVM.framework/Headers/ with -I$JAVA_HOME/include in CFLAGS as a minimum. You may also need to add -I$JAVA_HOME/include/darwin.

You will also need to change the paths used to link the .jnilib

Rob
  • 21
  • 2