java怎么写头文件_javah用法以及产生的头文件详解

  • Post author:
  • Post category:java


Command.java:

public class Command {

public static native String getStringFromC(String a);

static {

System.loadLibrary(“ndk-demo”);

}

}

#-d 指明产生文件的目录,

javac ./java/com/popoaichuiniu/jacy/examplelearning/Command.java -d .

#-classpath 指明查找的class文件的路径

#-d 指明产生头文件的目录

javah -classpath . -d ./jni com.popoaichuiniu.jacy.examplelearning.Command

产生如下头文件:

/* DO NOT EDIT THIS FILE – it is machine generated */

#include

/* Header for class com_popoaichuiniu_jacy_examplelearning_Command */

#ifndef _Included_com_popoaichuiniu_jacy_examplelearning_Command

#define _Included_com_popoaichuiniu_jacy_examplelearning_Command

#ifdef __cplusplus

extern “C” {//如果使用C++,包含这个头文件,就需要extern c。

#endif

/* * Class: com_popoaichuin



版权声明:本文为weixin_29186249原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。