【发布时间】:2022-11-12 01:59:42
【问题描述】:
我试图了解提供给我的文件是否可以使用 Jave Native Interface 来编写 Java 类并创建与 .h 头文件中的 C 函数相对应的 native 抽象方法。
所以,我现在拥有的是.ec 文件和.h 文件。两者都提供给了我。
我被要求尝试使用 JNI 从.ec 文件中调用函数。
但是,我注意到一些常见的 JNI 关键字,如 JNIEXPORT、JNICALL、JNIEnv*、jobject,在提供给我的 .ec 或 .h 文件中均不存在。
.h 文件如下所示:
#ifndef _BITMAP_H
#define _BITMAP_H 1
struct BITMAP
{
char *buffer; // buffer
int ax; // width
int ay; // height
int size; // buffer size
};
struct BITMAP *create(int ax, int ay);
void close( struct BITMAP *pbmp );
void drawLn( struct BITMAP *pbmp, int x1, int y1, int x2, int y2 );
void drawTxt(struct BITMAP *pbmp, char *szText, int x, int y );
void setPxl( struct BITMAP *pbmp, int x, int y );
#endif
这是使用 JNI 的有效文件吗? 我是 JNI 的初学者,但我怀疑 JNI 似乎不适用于这种文件定义。
是否有其他 Java 技术或库可以从 .ec 文件中调用这些方法?
我将不胜感激任何评论或解释。
谢谢你。
【问题讨论】:
标签: java c++ c java-native-interface jnienv