title: capture JNIENV* inside C++ lambda expression error
body: <p>I have in my Main.cpp file a JNI call like this:</p>
  
  <pre><code>JNIEXPORT jstring   JNICALL
      Java_packagename_MainActivity_GenerateAlphabet(JNIEnv *env, jobject thiz)
          {
              generateAlphabet([](string letters, string numbers) {
                          return (env)-&gt;NewStringUTF("test");
  
              });
          }
  </code></pre>
  
  <p>but this code gives me the error:</p>
  
  <p><strong>jni/Main.cpp: In lambda function:</strong></p>
  
  <p><strong>jni/Main.cpp:86:33: error: 'env' is not captured</strong></p>
  
  <p>I really need to use env in the lambda function, can anyone help me please.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>The accepted answer resolves the problem, but please keep in mind that you cannot return a value inside a lambda expression.</p>