JAVA ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2 JDWP exit erro

When running the program is suddenly the following exception occurs

ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2
JDWP exit error AGENT_ERROR_NO_JNI_ENV(183):  [util.c:840]

The reason:

1.JDK1.6.1
2. There is an error in the last debugging code, which causes the process not to terminate and take up the Console output, and such error occurs when starting debugging later.

Solutions:

At the end of the program, the main() function adds: System.exit(0);
System.exit(0); will cause the program to be terminated immediately, and if there are threads in the program that are still executing tasks, subsequent tasks will not be able to continue.

 

Read More: