title: JNI: How to convert a group of data from c++ to Java
body: <p>I'm trying to send some data from c++ to java using JNI.</p>
  
  <p>In c++ I have:</p>
  
  <pre>
  Array[0]:
  string name = "myName"
  int iterations = 16
  float value = 15
  ... etc</pre>
  
  <p>So I want to use JNI to return all data on Java, I'm trying this, but don't work</p>
  
  <p><pre>
  JNIEXPORT jobjectArray JNICALL Java_com_testing_data_MainActivity_getDATA(JNIEnv *env, jobject obj)
  {
  // 1º Create a temp object
  jobject dataClass
      {
          jstring name;
                  jint iterations;
                  jfloat value;
      };</p>
  
  <code>jobject tempObject = env-&gt;NewObject();
  
  // Get data in c++ format int temp object type
  std::vector&lt;dataClass &gt; data = getDataClass();  // First error, must be a c++ class, how could i get it?
  
  // How much memory i need?
  int dataSize = data.size();
  
  // Reserve memory in java format
  jint tempValues[dataSize];
  jobjectArray tempArray = env-&gt;NewObjectArray(dataSize,dataClass,0); // 2º Error, it doesn 't create the class
  
      // Temporal store data in jarray
  for (int i = 0; i &lt; dataSize ; i++)
  {
      tempArray[i].name = data[i].name;
              tempArray[i].iterations = data[i].iterations;
              tempArray[i].value = data[i].value;
  }
  
  return tempArray;   // return temp array
  </code></pre>
  
  <p>}</p>
  
  <p>Are correct this steps to return a structure/object with data? How is possible to fix the errors?</p>