正在创建。所以库出现致命错误。h没有这样的文件或目录 comrade@hp:~/workspace/JNI2/src$ls Prompt.c Prompt.class Prompt.h Prompt.java comrade@hp:~/workspace/JNI2/src$gcc-shared-o libPrompt.so-I/usr/lib/jvm/java-6-openjdk-i386/include-I/usr/lib/jvm/java-6-openjdk-i386/include/linux-lX11 Prompt.c/usr/lib/jvm/jre/lib/i386/server/libjvm.so Prompt.c:2:20:致命错误:Prompt.h:没有这样的文件或目录 编译终止。 提示c: #包括 #包括 ........

正在创建。所以库出现致命错误。h没有这样的文件或目录 comrade@hp:~/workspace/JNI2/src$ls Prompt.c Prompt.class Prompt.h Prompt.java comrade@hp:~/workspace/JNI2/src$gcc-shared-o libPrompt.so-I/usr/lib/jvm/java-6-openjdk-i386/include-I/usr/lib/jvm/java-6-openjdk-i386/include/linux-lX11 Prompt.c/usr/lib/jvm/jre/lib/i386/server/libjvm.so Prompt.c:2:20:致命错误:Prompt.h:没有这样的文件或目录 编译终止。 提示c: #包括 #包括 ........,gcc,java-native-interface,Gcc,Java Native Interface,我不理解什么?如评论所述,更改为: comrade@hp:~/workspace/JNI2/src$ ls Prompt.c Prompt.class Prompt.h Prompt.java comrade@hp:~/workspace/JNI2/src$ gcc --shared -o libPrompt.so -I/usr/lib/jvm/java-6-openjdk-i386/include -I/usr/lib/jvm/java-6-openjdk-i386/include/l

我不理解什么?

如评论所述,更改为:

comrade@hp:~/workspace/JNI2/src$ ls
Prompt.c  Prompt.class  Prompt.h  Prompt.java

comrade@hp:~/workspace/JNI2/src$ gcc --shared -o libPrompt.so -I/usr/lib/jvm/java-6-openjdk-i386/include -I/usr/lib/jvm/java-6-openjdk-i386/include/linux -lX11 Prompt.c /usr/lib/jvm/java-6-openjdk-i386/jre/lib/i386/server/libjvm.so
Prompt.c:2:20: fatal error: Prompt.h: No such file or directory
compilation terminated.


Prompt.c :  
#include <jni.h>
#include <Prompt.h>
........
发件人:

#包括 此变体用于系统头文件。 它在目录列表中搜索名为file的文件 由您指定,然后在系统目录的标准列表中。 您可以使用指定目录来搜索头文件 命令选项“-I”(参见第1.9节调用C预处理器)。 选项“-nostinc”禁止搜索标准系统 目录;在这种情况下,只搜索您指定的目录。 #包括“文件” 此变体用于您自己程序的头文件。 它首先在当前目录中搜索名为file的文件, 然后在用于系统头文件的相同目录中。 当前目录是当前输入文件的目录。 首先尝试它,因为它被假定为 当前输入文件引用的文件。 (如果使用“-I-”选项,则对 当前目录被禁止。)
尝试更改为
#include“Prompt.h”
尝试将包含行更改为
#include“Prompt.h”
,并使用双引号,而不是<>
#include "Prompt.h"
#include <file> This variant is used for system header files. It searches for a file named file in a list of directories specified by you, then in a standard list of system directories. You specify directories to search for header files with the command option `-I' (see section 1.9 Invoking the C Preprocessor). The option `-nostdinc' inhibits searching the standard system directories; in this case only the directories you specify are searched. #include "file" This variant is used for header files of your own program. It searches for a file named file first in the current directory, then in the same directories used for system header files. The current directory is the directory of the current input file. It is tried first because it is presumed to be the location of the files that the current input file refers to. (If the `-I-' option is used, the special treatment of the current directory is inhibited.)