Skip to main content
  1. About
  2. For Teams
Asked
Viewed 26k times
9

I'm not asking where I can find it on my own computer, I'm asking where I can get it.

I've done my google homework, and I didn't find the headers in those paths. There wasn't even a Header folder in my /System/Library/Java/JavaVirtualMachines/... and stuff and I don't have a Developer folder under root.

Now I'm pretty sure I don't have those headers installed, I checked the MacOS developer website but I only found some broken links.

Shouldn't OpenJDK or SunJDK provide the jni.h header for MacOS somewhere?

2

4 Answers 4

11

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/JavaVM.framework/Versions/A/Headers/jni.h

But this depends on your environment.

Sign up to request clarification or add additional context in comments.

1 Comment

Unfortunately, there wasn't a Headers directory. I removed JDK entirely and reinstalled, and it was there as you says.
10

You can use the java_home command to find the correct location. See the Oracle docs.

So for example in your makefile you could have:

JAVA_HOME:=`/usr/libexec/java_home`
CPPFLAGS:=-I $(JAVA_HOME)/include -I $(JAVA_HOME)/include/darwin

Note that you also need to add $(JAVA_HOME)/include/darwin to the include path so it can find jni_md.h which is the machine-specific part and is included by jni.h

Comments

8
  1. jdk8 download web url: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

download it and install.

  1. check java version:
sodino:~ sodino$ java -version 
java version "1.8.0_45" 
Java(TM) SE Runtime Environment (build 1.8.0_45-b14) 
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

3.find 'java' original path and ‘java_home':

sodino:~ sodino$ which java
/usr/bin/java
sodino:~ sodino$ ls -n /usr/bin/java
lrwxr-xr-x  1 0  0  74 Sep 30  2014 /usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java
sodino:~ sodino$/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java_home
/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home
  1. get ‘include’ folder and jni.h

    now you will find a ‘include’ folder with in ‘/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home’, and open it ‘jni.h’ will be found.

Comments

4

On Mac OS X 10.8.5, I use "/System/Library/Frameworks/JavaVM.framework/Headers", like:

HelloJNI.o : HelloJNI.c HelloJNI.h
gcc -I"/System/Library/Frameworks/JavaVM.framework/Headers" -fpic -c $< -o $@

BTW, I am using this version of Java:

java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)

Comments

Your Answer

Post as a guest

Required, but never shown

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.

Morty Proxy This is a proxified and sanitized view of the page, visit original site.