Search code examples
javac++java-native-interface

jni signature for method


My java method contains a function

 public static void downLoadProfileImage(String url, String fileName,  int tag, int from)

I am getting a JNI signature error:

if (JniHelper::getStaticMethodInfo(jniMethodInfo, packageName.c_str(), "downLoadProfileImage", "(Ljava/lang/String;Ljava/lang/String;I;I;)V")) 

If I just keep the two strings, everything works. But with two integers it throws an error? What am I doing wrong?


Solution

  • The two integer markers (I) shouldn't have a following semicolon. Try:

    (Ljava/lang/String;Ljava/lang/String;II)V
    

    Edit: The best way to work is probably to use "javap -s" to have java print the signatures for you. Also make sure you read and understand this page