构建时出现JNI错误

时间:2016-10-03 10:48:34

标签: java c++ java-native-interface native

我跟随" https://netbeans.org/kb/docs/cnd/beginning-jni-linux.html"针对JNI的Netbeans教程,但是当我构建项目时,我在Netbeans输出中得到了这个错误:

cd 'E:\Janhavi\Projects\JNIDemoCdl'
C:\cygwin64\bin\make.exe -f Makefile CONF=Debug clean
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .clean-conf
make[1]: Entering directory '/cygdrive/e/Janhavi/Projects/JNIDemoCdl'
rm -f -r build/Debug
rm -f dist/libJNIDemoCdl.so
make[1]: Leaving directory '/cygdrive/e/Janhavi/Projects/JNIDemoCdl'

CLEAN SUCCESSFUL (total time: 356ms)
cd 'E:\Janhavi\Projects\JNIDemoCdl'
C:\cygwin64\bin\make.exe -f Makefile CONF=Debug
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory '/cygdrive/e/Janhavi/Projects/JNIDemoCdl'
"/usr/bin/make"  -f nbproject/Makefile-Debug.mk dist/libJNIDemoCdl.so
make[2]: Entering directory '/cygdrive/e/Janhavi/Projects/JNIDemoCdl'
mkdir -p build/Debug/Cygwin-Windows/_ext/4d151f2
rm -f "build/Debug/Cygwin-Windows/_ext/4d151f2/JNIDemo.o.d"
gcc -shared -m64   -c -g -I/cygdrive/C/Program\ Files/Java/jdk1.7.0_79/include -I/cygdrive/C/Program\ Files/Java/jdk1.7.0_79/include/win32 -include /cygdrive/C/Program\ Files/Java/jdk1.7.0_79/include -include /cygdrive/C/Program\ Files/Java/jdk1.7.0_79/include/win32  -MMD -MP -MF "build/Debug/Cygwin-Windows/_ext/4d151f2/JNIDemo.o.d" -o build/Debug/Cygwin-Windows/_ext/4d151f2/JNIDemo.o /cygdrive/E/Janhavi/Projects/JNIDemoCdl/JNIDemo.c
cc1: fatal error: /cygdrive/C/Program Files/Java/jdk1.7.0_79/include: No such file or directory
compilation terminated.
make[2]: *** [nbproject/Makefile-Debug.mk:68: build/Debug/Cygwin-Windows/_ext/4d151f2/JNIDemo.o] Error 1
make[2]: Leaving directory '/cygdrive/e/Janhavi/Projects/JNIDemoCdl'
make[1]: *** [nbproject/Makefile-Debug.mk:59: .build-conf] Error 2
make[1]: Leaving directory '/cygdrive/e/Janhavi/Projects/JNIDemoCdl'
make: *** [nbproject/Makefile-impl.mk:40: .build-impl] Error 2

BUILD FAILED (exit value 2, total time: 557ms)

这是我对JNI的第一次尝试,我现在有点困惑。 请让我知道这是什么错误? 提前谢谢。

1 个答案:

答案 0 :(得分:0)

你的JNIDemoCdl正在调用make in cygwin64。这就是你在每个目录名之前得到/cygdrive的原因,因为它们是在cygwin挂载的驱动器中执行的。

我认为问题出在您最终获得的“程序文件”中的空间:

  

cc1:致命错误:/ cygdrive / C / Program Files / Java / jdk1.7.0_79 / include:   没有这样的文件或目录编译终止。

尝试将/Java/jdk1.7.0_79/存储在名称中没有空格的目录下,然后重新构建项目。