报错,但不影响运行ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2

参考:http://blog.csdn.net/zxl0016/article/details/7327125html

eclipse 3.4+jdk1.6java

编译正常经过,运行debug模式时报错api

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]网络

查找该错误缘由。发现是重定向输出的问题。eclipse

如下是网络资料原文jvm

装jdk1.6了把,呵呵~ 我也碰到过这问题。 
这是我之前在网上找到的,但愿对你有帮助。 
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] 

这是怎么回事呢?如今的Java SE 6已经到了RC的阶段了啊?这样的错误SUN不会有吧~~ 

通过我仔细的查阅Java Doc,发现其中有这么一段话: 

http://download.java.net/jdk6/docs/api/java/io/Console.html 

"Whether a virtual machine has a console is dependent upon the underlying platform and also upon the manner in which the virtual machine is invoked. If the virtual machine is started from an interactive command line without redirecting the standard input and output streams then its console will exist and will typically be connected to the keyboard and display from which the virtual machine was launched. If the virtual machine is started automatically, for example by a background job scheduler, then it will typically not have a console." ">http://download.java.net/jdk6/docs/api/java/io/Con..." 

翻译一下: 

虚拟机是否有一个控制台Console取决于所依赖的平台和虚拟机解析该方法的方式。若是虚拟机是从一个交互式的命令行中启动的,而没有重定向标准输入和输出流,那么虚拟机会自动的链接到键盘做为标准输入,而且把启动虚拟机的地方做为标准输出。若是虚拟机是自动启动的,例如经过后台的一个任务计划,那么典型的状况就是没有Console控制台......。 

因而,思考一下咱们运行上面程序的地点——Eclipse等集成开发环境,这对于上面描述中的把启动虚拟机的地方做为标准输出来讲是不合适的,这里的Console()返回的默认状况下是Null,因而就产生了上面的出错信息。(也许将来Eclipse会有所改进吧) 

怎么解决该问题呢?这里提供两条思路给你们(已经实际操做过,能够实现功能的正常运做) 

一、使用命令行进行运行,编译可使用集成开发环境。这样能够完成标准输出。 
二、在程序中重定向标准输出到其余的设备或者方式(例如写到文本文件),这样也能够"比较不方便的"完成该功能。
函数

三、在main函数结束时,添加system.exit(0);.net

相关文章
相关标签/搜索