Java 错误:JDWP 无法获取 JNI 1.2 环境

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2225737/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 04:56:24  来源:igfitidea点击:

ERROR: JDWP Unable to get JNI 1.2 environment

javaeclipsejdwp

提问by Carlos Blanco

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

在 Eclipse 中调试后出现此错误。不过调试成功。

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?

这是什么意思?

采纳答案by Pascal Thivent

Looks like http://bugs.sun.com/view_bug.do?bug_id=6476706which 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).

看起来像http://bugs.sun.com/view_bug.do?bug_id=6476706,它的优先级很低,仍然没有修复。绝对是野马错误,但没有明确的解释(根据错误报告者的说法,似乎是随机发生的)。

回答by bmargulies

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

这显然是一个JVM错误。这是无害的和不可预测的。

回答by Vasile Surdu

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

只需添加System.exit(0);到您的主要方法的末尾。

That's all you have to do.

这就是你所要做的。

回答by CocheLee

@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.

@Everyone 我在使用图像 API 通过网络读取和写入文件时遇到了这个问题,当我运行使用本地文件的程序时,这不会发生。在验证我的结果后,我确认它确实没有任何伤害(至少在我的调试中)。现在我正在阅读这篇文章,我不再研究它。

回答by Ian

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]

回答by Adil Ras

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 eclipsewhich works for me most of the time.

我注意到当我使用存储在我的 USB 驱动器上的工作区时会发生这种情况,有时在我的工作网络上。这不是主要问题,似乎对我的任何程序的执行都没有任何影响。我测试了@Vasile Surdu 添加System.exit(0);到 main 方法末尾的解决方案并且它有效。Another solution is to restart eclipse大多数时候这对我有用。