我正在做的项目中也用到jni,文件也是包含在包中的
没有问题,肯定是可以用包的。
是不是其他问题?

解决方案 »

  1.   

    你编译后的.h文件名,包括包名的名称么?如com_0005cJavaExpress.h
      

  2.   

    .h文件使用命令javah实现的
    文件名也带着包名,并且.h的函数声明也带着包名
    如: 我的包是package jp.co.screen.pia.hfw.util;
    .class 文件为DragAndDrop.class  
    生成的.h为jp_co_screen_pia_hfw_util_DragAndDrop.h.java中的方法public native static void setWindowLong();
    在.h中为
    JNIEXPORT void JNICALL Java_jp_co_screen_pia_hfw_util_DragAndDrop_setWindowLong
      (JNIEnv *, jclass);希望对你有帮助
      

  3.   

    我得源文件如下:
    package vanda.expression;public class JavaExpress{
    public native int MathematicCompute  (byte[] express,StringBuffer result);
    public native int BusinessDecision(byte[] businessExpress);
    public native int CreatDataPool(int HashRecNum);
    public native int FreeDataPool();
    public native int SetVariableToDataPool(byte[] VarName,byte[] VarData,int protect);
    public native int GetVariableFromDataPool(byte[] VarName,StringBuffer VarData);
    public native int RemoveLikeVariable(byte[] PreName);
    public native int RemoveLowerVariable(int Protect);
    public native int UnloadDataPool(StringBuffer str,int len);
    public native int ReloadDataPool(byte[] str);

    }生成的JavaExpress.class文件
    使用javah vanda\express\JavaExpress生成.h 文件,生成的文件名为vanda_0005cexpression_0005cJavaExpress.h,为什么?
      

  4.   

    to:LoveRose(旺旺)
    你使用的java的jdk的版本是什么,我使用Jsdk 1.4.1
      

  5.   

    我把你的文件跑了一遍,文件的根目录为f:/projectjavac -d f:/project JavaExpress.java在f:/project下生了包vanda.expression并生成JavaExpress.class然后执行javah -jni vanda.expression.JavaExpress生成如下vanda_expression_JavaExpress.h
      

  6.   

    解决了,我在执行javah命令时,使用的"\"而不是"."。
    如下javah vanda\express\JavaExpress,所以导致生成.h的文件名称不正确。
    谢谢!LoveRose(旺旺),结贴了。