ERROR: JDWP Unable to get JNI 1.2 environment

JavaEclipseJdwp

Java Problem Overview


I get this error after debugging in Eclipse. The debug is successful though.

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

What does it mean?

Java Solutions


Solution 1 - Java

Just add System.exit(0); to the end of your main method.

That's all you have to do.

Solution 2 - Java

Looks like http://bugs.sun.com/view_bug.do?bug_id=6476706 which has low priority and is still not fixed. Definitely a Mustang bug but no clear explanation (seems to occur pretty randomly according to the bug reporters on top of that).

Solution 3 - Java

It's apparently a JVM bug. It's harmless and unpredictable.

Solution 4 - Java

Happens on something as simple as this tutorial

//trim spaces
String s2 = "Welcome!";
int len1 = s2.length();
System.out.println(len1);
String s3 = s2.trim();
System.out.println(s3.length());

Happens if run program too fast multiple times so something to do with system performance?

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

Solution 5 - Java

@Everyone I'm facing this problem using the image API reading and writing files over the network, when I run the program working with local files this doesn't happen. After verifiying my results I confirmed that it really doesn't do any harm (at least on my debugging). Now that I'm reading this post I stopped looking into it.

Solution 6 - Java

I have noticed this occurs when I am using a workspace stored on my USB drive and sometimes on my work's network. It is not a major issue and doesnt seem to have any effect on the execution of any of my programs. I tested @Vasile Surdu's solution of addingSystem.exit(0); to the end of the main method and it works. Another solution is to restart eclipse which works for me most of the time.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionCarlos BlancoView Question on Stackoverflow
Solution 1 - JavaVasile SurduView Answer on Stackoverflow
Solution 2 - JavaPascal ThiventView Answer on Stackoverflow
Solution 3 - JavabmarguliesView Answer on Stackoverflow
Solution 4 - JavaIanView Answer on Stackoverflow
Solution 5 - JavaCocheLeeView Answer on Stackoverflow
Solution 6 - JavaAdil RasView Answer on Stackoverflow