title: Jni FindClass returns NULL
body: <p>I got c++ structs in header file,</p>
  
  <pre><code>struct StatusLine
  {
      static jclass Class; // Lorg/apache/http/StatusLine;
      static jmethodID GetStatusCode; // ()I
  };
  
  struct ByteArrayOutputStream 
  {
      static jclass Class; // Ljava/io/ByteArrayOutputStream;
      static jmethodID Constructor; // ()V
      static jmethodID Close; // ()V
      static jmethodID ToByteArray; // ()[B
  };
  
  struct HttpEntity
  {
      static jclass Class; // Lorg/apache/http/HttpEntity;
      static jmethodID WriteTo; // (Ljava/io/OutputStream;)V
      static jmethodID GetContent; // ()Ljava/io/InputStream;
  };  
  </code></pre>
  
  <p>and cpp file is </p>
  
  <pre><code> #define JAVA_STATUS_LINE_CLASS             "org/apache/http/StatusLine"
   #define JAVA_HTTP_ENTITY_CLASS             "org/apache/http/HttpEntity"
   #define JAVA_BYTE_ARRAY_OUTPUT_STREAM_CLASS "java/io/ByteArrayOutputStream"
  
   jclass StatusLine::Class = 0;
   jmethodID StatusLine::GetStatusCode = 0;
  
   jclass  ByteArrayOutputStream::Class = 0;
   jmethodID ByteArrayOutputStream::Constructor = 0;
   jmethodID ByteArrayOutputStream::Close = 0;
   jmethodID ByteArrayOutputStream::ToByteArray = 0;
  
   jclass HttpEntity::Class = 0;
   jmethodID HttpEntity::WriteTo = 0;
   jmethodID HttpEntity::GetContent = 0;
  
   void initializeJniPointers()
   {
        StatusLine::Class = GetJniEnv()-&gt;FindClass(JAVA_STATUS_LINE_CLASS);
        StatusLine::GetStatusCode = GetJniEnv()-&gt;GetMethodID(StatusLine::Class, "getStatusCode", "()I");
  
  
        ByteArrayOutputStream::Class = GetJniEnv()-&gt;FindClass(JAVA_BYTE_ARRAY_OUTPUT_STREAM_CLASS);
        ByteArrayOutputStream::Constructor = GetJniEnv()-&gt;GetMethodID(ByteArrayOutputStream::Class, "&lt;init&gt;", "()V");
        ByteArrayOutputStream::Close = GetJniEnv()-&gt;GetMethodID(ByteArrayOutputStream::Class, "close", "()V");
        ByteArrayOutputStream::ToByteArray = GetJniEnv()-&gt;GetMethodID(ByteArrayOutputStream::Class, "toByteArray", "()[B");
  
        HttpEntity::Class = GetJniEnv()-&gt;FindClass(JAVA_HTTP_ENTITY_CLASS);
        HttpEntity::WriteTo = GetJniEnv()-&gt;GetMethodID(HttpEntity::Class, "writeTo", "(Ljava/io/OutputStream;)V");
        HttpEntity::GetContent = GetJniEnv()-&gt;GetMethodID(HttpEntity::Class, "getContent", "()Ljava/io/InputStream;");
   }
  </code></pre>
  
  <p>function initializeJniPointers() crushes on line StatusLine::GetStatusCode = GetJniEnv()->GetMethodID(); because StatusLine::Class is NULL. 
     But! I notice that:
  If I write this in some java file of the project
       StatusLine l = new StatuLine()
       {
           ...
       }</p>
  
  <p>Function crushes on ByteArrayOutputStream::Constructor because ByteArrayOutputStream::Class is NULL, if I create an object of ByteArrayOutputStream in java, function will go further to the next object, etc... I notice that: If I just declare a variable of ByteArrayOutputStream, findClass will return NULL. </p>
  
  <p>Could someone explain me what to do? BTW I use Android 2.3.5 device Samsung GT-S5363, I tried other vertions of android (elder) and devices and it works fine. </p>