title: Sending parameters to java via c++
body: <p>My java class has a static function defined as follows:</p>
  
  <pre><code>public static void logEvent(final String eventName, final String jObject) {
          //Function data
      }
  </code></pre>
  
  <p>Now my cpp file has the following function</p>
  
  <pre><code>void PingoScreen::callApslarIntegration(){
      char* eventName="bingo";
      JniMethodInfo t;  
  
  if (JniHelper::getStaticMethodInfo(t, "com/myapp/test/ApslarSetup","logEvent", "()V")) {
      t.env-&gt;CallStaticVoidMethod(t.classID, t.methodID);
      t.env-&gt;DeleteLocalRef(t.classID);
    }
  }
  </code></pre>
  
  <p>How can i send two string params to the JAVA function via JNI  ?</p>
  
  <p>Kind Regards</p>
  
  <p>===============================================================</p>
  
  <pre><code>void PingoScreen::callApsIntegration() {
  
      JniMethodInfo t;
  
      if (JniHelper::getStaticMethodInfo(t, "com/myapp/test/ApslarSetup",
              "logJSONEvent", "()V")) {
  
          const char* cstr1 = "Test1";
          const char* cstr2 = "Test2";
  
          jstring jstr1 = t.env-&gt;NewStringUTF(cstr1);
          jstring jstr2 = t.env-&gt;NewStringUTF(cstr2);
  
          t.env-&gt;CallStaticVoidMethod(t.classID, t.methodID,jstr1,jstr2);
          t.env-&gt;DeleteLocalRef(t.classID);
      }
  }
  </code></pre>
  
  <p>The above function causes a crash ?</p>
  
  <p>==================================</p>
  
  <p>Finally got it to work</p>
  
  <pre><code>void PingoScreen::callApslarIntegration() {
      JniMethodInfo t;
      if (JniHelper::getStaticMethodInfo
                  (t, "com/nbs/test/ApslarSetup",
                  "logJSONEvent",
                  "(Ljava/lang/String;Ljava/lang/String;)V")) {
  
          const char* cstr1 = "Test1";
          const char* cstr2 = "Test2";
  
          jstring jstr1 = t.env-&gt;NewStringUTF(cstr1);
          jstring jstr2 = t.env-&gt;NewStringUTF(cstr2);
  
          t.env-&gt;CallStaticVoidMethod(t.classID, t.methodID,jstr1,jstr2);
          t.env-&gt;DeleteLocalRef(t.classID);
      }
  }
  </code></pre>
  
  <p>The crash was due to the line</p>
  
  <pre><code>if (JniHelper::getStaticMethodInfo
                      (t, "com/nbs/test/ApslarSetup",
                      "logJSONEvent",
                      "(Ljava/lang/String;Ljava/lang/String;)V"))
  </code></pre>
  
  <p>The signiture had to be <code>Ljava/lang/String;Ljava/lang/String;</code> and not <code>Ljava/lang/String;Ljava/lang/String</code> (notice the last semi-colon)</p>