在C++向JAVA提供调用接口时,需要一个指向java class的指针,怎么实现,JNA库中有方法吗 20
2个回答
展开全部
public interface MyCDll extends Library {
MyCDll INSTANCE = (MyCDll)Native.loadLibrary("MyCDll", MyCDll.class);
public static class CFile extends Structure {
public ByteByReference _ptr = new ByteByReference();
public int _cnt;
public ByteByReference _base = new ByteByReference();
public int _flag;
public int _file;
public int _charbuf;
public int _bufsiz;
public ByteByReference _tmpfname = new ByteByReference();
public static class ByReference extends CFile
implements Structure.ByReference{}
public static class ByValue extends CFile
implements Structure.ByValue{}
}
public CFile.ByReference fopen(byte[] filename,int len1, byte[] model,int len2);
public int fread(byte[] br, int size, int count, CFile f);
public int fclose(CFile br);
}
这是用java模拟的C的File类。java调用需要的写好的dll或so的动态库。动态库中的所有方法都可以用JNA来描述
MyCDll INSTANCE = (MyCDll)Native.loadLibrary("MyCDll", MyCDll.class);
public static class CFile extends Structure {
public ByteByReference _ptr = new ByteByReference();
public int _cnt;
public ByteByReference _base = new ByteByReference();
public int _flag;
public int _file;
public int _charbuf;
public int _bufsiz;
public ByteByReference _tmpfname = new ByteByReference();
public static class ByReference extends CFile
implements Structure.ByReference{}
public static class ByValue extends CFile
implements Structure.ByValue{}
}
public CFile.ByReference fopen(byte[] filename,int len1, byte[] model,int len2);
public int fread(byte[] br, int size, int count, CFile f);
public int fclose(CFile br);
}
这是用java模拟的C的File类。java调用需要的写好的dll或so的动态库。动态库中的所有方法都可以用JNA来描述
2011-11-25
展开全部
用jni,我也没用过,我也是在找方法,但是大多数人都说用JNI......
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询