当前位置: 技术问答>java相关
接着请教jni的问题,使用vc时编译产生错误?!
来源: 互联网 发布时间:2015-02-22
本文导语: 用的是人民邮电出版社的《java网络高级编程》中的关于本地方法JNI的例子cNative.java 代码如下: //java源程序 /*源程序清单12-12*/ package test; public class cNative { public native void testNative(int m); //声明本地...
用的是人民邮电出版社的《java网络高级编程》中的关于本地方法JNI的例子cNative.java
代码如下:
//java源程序
/*源程序清单12-12*/
package test;
public class cNative
{
public native void testNative(int m); //声明本地方法
static
{
System.loadLibrary("dllNative");
}
//装载动态连接库文件,设以后要生成的动态连接库文件名为dllNative.dll
public cNative()
{
}
public void printStr(int m)
{
String str="";
for(int i=0;iGetMethodID(env,jc,"printStr","(I)V");
printf("VC call java method.n");
(*env)->CallObjectMethod(env,obj,jm,x);
}
并且拷贝了cNative.到其目录,并加到header files栏中
但是编译产生了错误,可我都是教程作的阿
出错信息如下:
Compiling...
dllNative.cpp
e:test3dllNativedllNative.cpp(11) : error C2819: type 'JNIEnv_' does not have an overloaded
member 'operator ->'
e:program filesmicrosoft visual studiovc98includejni.h(746) : see declaration of
'JNIEnv_'
e:test3dllNativedllNative.cpp(11) : error C2227: left of '->GetObjectClass' must point to
class/struct/union
e:test3dllNativedllNative.cpp(12) : error C2819: type 'JNIEnv_' does not have an overloaded
member 'operator ->'
e:program filesmicrosoft visual studiovc98includejni.h(746) : see declaration of
'JNIEnv_'
e:test3dllNativedllNative.cpp(12) : error C2227: left of '->GetMethodID' must point to
class/struct/union
e:test3dllNativedllNative.cpp(14) : error C2819: type 'JNIEnv_' does not have an overloaded
member 'operator ->'
e:program filesmicrosoft visual studiovc98includejni.h(746) : see declaration of
'JNIEnv_'
e:test3dllNativedllNative.cpp(14) : error C2227: left of '->CallObjectMethod' must point to
class/struct/union
e:test3dllNativedllNative.cpp(16) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
dllNative.dll - 7 error(s), 0 warning(s)
请指点
谢谢
代码如下:
//java源程序
/*源程序清单12-12*/
package test;
public class cNative
{
public native void testNative(int m); //声明本地方法
static
{
System.loadLibrary("dllNative");
}
//装载动态连接库文件,设以后要生成的动态连接库文件名为dllNative.dll
public cNative()
{
}
public void printStr(int m)
{
String str="";
for(int i=0;iGetMethodID(env,jc,"printStr","(I)V");
printf("VC call java method.n");
(*env)->CallObjectMethod(env,obj,jm,x);
}
并且拷贝了cNative.到其目录,并加到header files栏中
但是编译产生了错误,可我都是教程作的阿
出错信息如下:
Compiling...
dllNative.cpp
e:test3dllNativedllNative.cpp(11) : error C2819: type 'JNIEnv_' does not have an overloaded
member 'operator ->'
e:program filesmicrosoft visual studiovc98includejni.h(746) : see declaration of
'JNIEnv_'
e:test3dllNativedllNative.cpp(11) : error C2227: left of '->GetObjectClass' must point to
class/struct/union
e:test3dllNativedllNative.cpp(12) : error C2819: type 'JNIEnv_' does not have an overloaded
member 'operator ->'
e:program filesmicrosoft visual studiovc98includejni.h(746) : see declaration of
'JNIEnv_'
e:test3dllNativedllNative.cpp(12) : error C2227: left of '->GetMethodID' must point to
class/struct/union
e:test3dllNativedllNative.cpp(14) : error C2819: type 'JNIEnv_' does not have an overloaded
member 'operator ->'
e:program filesmicrosoft visual studiovc98includejni.h(746) : see declaration of
'JNIEnv_'
e:test3dllNativedllNative.cpp(14) : error C2227: left of '->CallObjectMethod' must point to
class/struct/union
e:test3dllNativedllNative.cpp(16) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
dllNative.dll - 7 error(s), 0 warning(s)
请指点
谢谢
|
写错了
jc=env->GetObjectClass(obj);
jm=env->GetMethodID(jc,"printStr","(I)V");
printf("VC call java method.n");
env->CallObjectMethod(obj,jm,x);
jc=env->GetObjectClass(obj);
jm=env->GetMethodID(jc,"printStr","(I)V");
printf("VC call java method.n");
env->CallObjectMethod(obj,jm,x);
jc=env->GetObjectClass(obj);
jm=env->GetMethodID(jc,"printStr","(I)V");
printf("VC call java method.n");
env->CallObjectMethod(obj,jm,x);
jc=env->GetObjectClass(obj);
jm=env->GetMethodID(jc,"printStr","(I)V");
printf("VC call java method.n");
env->CallObjectMethod(obj,jm,x);
|
JNIEXPORT void JNICALL Java_cNative_testNative(JNIEnv *env,jobject obj,jint m){
方法名字错了,区分大小写的
方法名字错了,区分大小写的
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。