如何在 OS X Lion 上安装 Java 本机开发标头
我正在尝试构建一个JNI项目,但我似乎找不到JNI标头(例如)。我已经从 https://developer.apple.com/downloads/ 安装了“Java for Mac OS X 10.7 Developer Package”。jni.h
各种在线资源建议标头应该在诸如 或 之类的位置,但我在任何地方都找不到它们 - 安装程序似乎没有创建它们。/System/Library/Frameworks/JavaVM.framework/Headers
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/include
我看到其他JDK组件 - 例如,- 但不是JNI头文件。有什么建议吗?/System/Library/Frameworks/JavaVM.framework/Commands/javah
更新:technomage指出,苹果现在在 下安装 JDK,而 JNI 标头位于 。/Library/Java/JavaVirtualMachines
/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home/include/jni.h
但我仍然坚持我的实际目标,即为LevelDB构建JNI包装器(根据 github.com/fusesource/leveldbjni 中的指令)。为了将 Maven 指向正确的 JDK,我将其添加到 PATH 的前面,并将 JAVA_HOME 设置为 。在晃动了一会儿之后,Maven现在失败了:/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home/bin
/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home
[INFO] --- maven-hawtjni-plugin:1.5:build (default) @ leveldbjni-osx ---
[INFO] Extracting /Users/steve/leveldb/leveldbjni/leveldbjni/target/leveldbjni-99-master-SNAPSHOT-native-src.zip to /Users/steve/leveldb/leveldbjni/leveldbjni-osx/target/native-build-extracted
[INFO] executing: /bin/sh -c ./configure --disable-ccache --prefix=/Users/steve/leveldb/leveldbjni/leveldbjni-osx/target/native-build/target --with-leveldb=/Users/steve/leveldb/leveldb --with-snappy=/Users/steve/leveldb/snappy-1.0.3 --with-universal --with-leveldb=/Users/steve/leveldb/leveldb --with-snappy=/Users/steve/leveldb/snappy-1.0.3
...
[INFO] configure: JAVA_HOME was set, checking to see if it's a JDK we can use...
[INFO] checking if '/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home' is a JDK... no
[INFO] configure: javac was on your path, checking to see if it's part of a JDK we can use...
[INFO] checking if '/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home' is a JDK... no
[INFO] configure: Taking a guess as to where your OS installs the JDK by default...
[INFO] checking if '/System/Library/Frameworks/JavaVM.framework' is a JDK... no
[INFO] configure: error: JDK not found. Please use the --with-jni-jdk option
我无法确定Maven正在查看什么来识别“我们可以使用的JDK”?一些挖掘使我 http://www.arm4.org/trac/browser/branches/architecture/m4/jni.m4 它似乎在几个地方寻找jni.h并尝试编译它,但我不知道这个jni.m4是否有任何实际的关系Maven。我确实有jni.h在/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home/include/。