JDK 1.8 on Linux missing JNI include file

戏子无情 提交于 2019-12-04 17:11:32

问题


I am trying to compile the following project:

https://github.com/entropia/libsocket-can-java

I always get this error message? Does anyone know how to fix it, is it possibly a bug in JDK 1.8.0.11 on Linux (x64 Debian Wheezy)?

In file included from jni/de_entropia_can_CanSocket.h:2:0,
             from jni/cansocket.cpp:23:
/opt/jdk1.8.0_11/include/jni.h:45:20: fatal error: jni_md.h: No such file or directory
#include "jni_md.h"
                ^

回答1:


It seems so. #include "jni_md.h" would include the file in the same directory as jni.h, but it is placed in linux folder.

In previous JDK versions it seems that file and another were place in include/linux folder, but there are symlinks to both files in include.

So you can just create symlinks to both files:

$ sudo ln -s /opt/jdk1.8.0_11/include/linux/jni_md.h /opt/jdk1.8.0_11/include/jni_md.h
$ sudo ln -s /opt/jdk1.8.0_11/include/linux/jawt_md.h /opt/jdk1.8.0_11/include/jawt_md.h

Edit

As stated in the comments by Absurd-Mind and Mikkel, there is also the option to add that path to the makefile compiler options:

-I$(JAVA_HOME)/include/linux/



回答2:


No, this is not a bug. The correct way to solve this issue is to provide -I${JAVA_HOME}/include -I${JAVA_HOME}/include/linux compiler options. This way your build scripts remain portable.

The OP is facing the problem on Linux, but if anybody is facing this problem on windows, please add following compiler options.

-I"%JAVA_HOME%\include" -I"%JAVA_HOME%\include\win32" where JAVA_HOME points to your JDK installation directory, usually 'C:\Program Files\Java\jdk1.{7|8}.{}_{xx}'




回答3:


It is also possible that there are more than one JDK that have been deployed, and the one that is linked to $JAVA_HOME is not the correct one. You need to update $JAVA_HOME to that that contains the jni_md.h file.



来源:https://stackoverflow.com/questions/24996017/jdk-1-8-on-linux-missing-jni-include-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!