title: how to write and read from bytebuffer passing from java to jni
body: <p>I need help with my android project.
  I want to pass a buffer from java to jni, and my C++ code will populate the data. Then java will display them on the screen. 
  I am not familiar much with C++ and have no idea how to write to write to the buffer.</p>
  
  <p>this is what i got. 
  in java</p>
  
  <pre><code>ByteBuffer bb = ByteBuffer.allocateDirect(216);
          IssmJni.processBuffer(bb);
  </code></pre>
  
  <p>native method</p>
  
  <pre><code>public static native void processBuffer(ByteBuffer bb);
  </code></pre>
  
  <p>I don't use jni_onload, so no javah
  in C++</p>
  
  <pre><code>static void fillBuffer(JNIEnv *env, jclass clazz, jobject buf)
      {
          double *dBuf = env-&gt;GetDirectBufferAddress(env, buf);
  
      }
  </code></pre>
  
  <p>I am stuck here, can I do double <em>dbuf? or is it has to be a char</em>?</p>
  
  <p>Let said I want to write 1,2,3,4,5 to this dbuf, how do I do it? 
  i am thinking of dbuf.put(1); ... dbuf.put(5) but it is not working.
  and after populating it, do I just call bb.get(position) in java?</p>
  
  <p>Someone clarify this for me please, example would be appreciated
  Thank you</p>
  
  <p>this is my table of native methods</p>
  
  <p>static JNINativeMethod method_table[] = {</p>
  
  <pre><code>{"fac"      ,     "(J)J" , (void *) factorial},
      {"getBuffer",     "()[D" , (void *) getBufferNative},
      //{"processBuffer", "(Ljava/nio/ByteBuffer)V", (void *) fillBuffer}};
  </code></pre>
  
  <p>The other two works fine except the last one. </p>