Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to make VTK compile on a Mac Air machine. I am using CMake 2.8-9, using Xcode4 as the generator. If I press the Configure button with VTK_WRAP_JAVA not checked, it will go with no errors. However I definitely need to use the wrap java since my main program is in Java and I need to get to VTK which is c++.

As soon as I check the wrap Java, I get Could NOT find JNI. It apparently is looking for jni.h which in Linux there is no problem finding, but in the Mac it apparently can't find it.

I did a locate jni.h and got

new-host-2:~ geraldkolodny$ locate jni.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/JavaVM.framework/Versions/A/Headers/jni.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/JavaVM.framework/Versions/A/Headers/jni.h
/Library/Java/JavaVirtualMachines/jdk1.7.0_07.jdk/Contents/Home/include/jni.h

I tried to manually put into JAVA_INCLUDE_PATH2 either entry 2 or 3 (without the jni.h at the end), but it still can't find jni.h.

Xcode used to have a template for jni but that is now gone in the latest version. I am fresh out of ideas on how to solve this problem. I'd be grateful for any suggestions.

share|improve this question
up vote 1 down vote accepted

I am trying to use SWIG to create a Java interface to a C++ numerical algorithm I've developed. I was able to successfully do this in work (on a Linux blade) but had a problem doing it on my mac at home because when I would run my small build script to compile the SWIG wrapper class, I would likewise get a complaint about the inability to find jni.h.

After hunting around doc pages and apple support I was able to locate jni.h on my system here:

/System/Library/Frameworks/JavaVM.framework/Headers/jni.h

(this may also be a result of having previously installed the Java developer tools and runtime)

when I added this include path in my build script:

g++  -fpic -I. -I/System/Library/Frameworks/JavaVM.framework/Headers -c *cpp

this error complaint went away. Not exactly the same development issue but maybe if you reference this location for jni.h your build error may likewise go away.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .