JNI: Class not found or FindClass returns NULL
<p>I'm trying JNI with C++. But I get this error: <code>Class not found!</code>. I searched other solved, but not working for me.<br>
<strong>Code.java:</strong></p>

<pre><code>package com.xxx;

public class Code
{
  public void getMessage()
  {
    System.out.println("Hello World!");
  }
}
</code></pre>

<p><strong>main.cpp:</strong></p>

<pre><code>#include &lt;jni.h&gt;
#include &lt;iostream&gt;
using namespace std;

int main(int argc, char* argv[])
{
  JavaVM* jvm;
  JNIEnv* env;
  JavaVMInitArgs jvm_args;
  JavaVMOption options[1];

  options[0].optionString = "-Djava.class.path=myclasses";
  jvm_args.version = JNI_VERSION_1_2;
  jvm_args.options = options;
  jvm_args.nOptions = 1;
  jvm_args.ignoreUnrecognized = JNI_TRUE;

  jint res = JNI_CreateJavaVM(&amp;jvm, (void**)&amp;env, &amp;jvm_args);
  if (res &lt; 0)
  {
    cout &lt;&lt; "Cannot create JVM!\n";
    exit(1);
  }

  jclass class_ = env-&gt;FindClass("com/xxx/Code");
  if (class_ == 0)
  {
    cout &lt;&lt; "Code class not found!\n";
    exit(1);
  }

  jmethodID method_id = env-&gt;GetMethodID(class_, "getMessage", "()V");
  if (method_id == 0)
  {
    cout &lt;&lt; "getMessage() method not found!\n";
    exit(1);
  }

  env-&gt;CallVoidMethod(class_, method_id);

  return 0;
}
</code></pre>

<p><strong>Directory for my files:</strong><br>
<a href="https://i.stack.imgur.com/hJgB0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hJgB0.png" alt="Directory"></a></p>

<p>I tried <code>-Djava.class.path=myclasses/com/xxx</code> and <code>env-&gt;FindClass("Code");</code>. Also I tried <code>-Djava.class.path=myclasses</code> and <code>env-&gt;FindClass("com/xxx/Code");</code>. But both not working. What is reason of <code>Code class not found!</code> message?</p>