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 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会有所改进吧)
怎么解决该问题呢?这里提供两条思路给大家(已经实际操作过,可以实现功能的正常运作)
1、使用命令行进行运行,编译可以使用集成开发环境。这样可以完成标准输出。
2、在程序中重定向标准输出到其他的设备或者方式(例如写到文本文件),这样也可以“比较不方便的”完成该功能。
小结:
此错误一般发生于设置输出方法,例:先调用了org.dom4j.io.SAXReader的reader()方法,再去设置 ElementHandler
总结:
重申!!文档很重要,特别是官方文档和一些说明书性质的文献资料。预期看什么XX天精通YY技术,还不如首先把官方的文档通读一遍。推荐Java Doc和MSDN Library。
分享到:
相关推荐
NULL 博文链接:https://cici9898-007.iteye.com/blog/1813855
<jvm-arg>-Xms512m</jvm-arg> <jvm-arg>-Xss128k</jvm-arg> <jvm-arg>-Xmn184m</jvm-arg> <jvm-arg>-XX:ParallelGCThreads=20</jvm-arg> <jvm-arg>-XX:+UseConcMarkSweepGC</jvm-arg> <jvm-arg>-XX:+UseParNewGC</...
此资源有两个文件,含 nginx-upstream-jvm-route 和 nginx 对应版本,都是tar.gz文件。 安装方法网上很多就不写了,亲测可用。 不用担心版本不匹配造成安装失败,再浪费积分去到处下载尝试的烦恼。 此资源有两个文件...
nginx-upstream-jvm-route 支持nginx版本1.15 解决nginx: [emerg] invalid parameter "srun_id=tomcat1" 问题
kotlinx-coroutines-io-jvm-0.1.1.jar
Moonbox(月光宝盒)是JVM-Sandbox生态下的,基于jvm-sandbox-repeater重新开发的一款流量回放平台产品。在jvm-sandbox-repeater基础上提供了更加丰富功能,同时便于线上部署和使用,更多对比参考。 使用场景 你...
官方离线安装包,测试可用。使用rpm -ivh [rpm完整包名] 进行安装
nginx_upstream_jvm_route 是一个 Nginx 的扩展模块,用来实现基于 Cookie 的 Session Sticky 的功能。 安装方法(进入Nginx源码目录): #patch -p0 < /path/to/this/directory/jvm_route.patch # ./configure -...
<prop key="hibernate.hbm2ddl.auto">update</prop> --> !-- Turn batching off for better error messages under PostgreSQL <prop key="hibernate.jdbc.batch_size">100</prop> --> <prop key=...
赠送jar包:metrics-jvm-3.1.5.jar; 赠送原API文档:metrics-jvm-3.1.5-javadoc.jar; 赠送源代码:metrics-jvm-3.1.5-sources.jar; 赠送Maven依赖信息文件:metrics-jvm-3.1.5.pom; 包含翻译后的API文档:...
jvm-npm, 适用于JVM的兼容CommonJS模块加载器 JVM上Javascript运行时中的NPM模块加载支持。 实现基于 http://nodejs.org/api/modules.html,应该完全兼容。 当然,不包括完整的node.js API,因此不要期望依赖于它的...
jdk 17需要 新增 配置 如下 jvm参数 --add-opens=java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED --add-opens=java.base/jdk.internal.org.objectweb.asm.tree=ALL-UNNAMED
赠送jar包:metrics-jvm-3.1.5.jar; 赠送原API文档:metrics-jvm-3.1.5-javadoc.jar; 赠送源代码:metrics-jvm-3.1.5-sources.jar; 赠送Maven依赖信息文件:metrics-jvm-3.1.5.pom; 包含翻译后的API文档:...
jvm-mon:基于控制台的JVM监视
jvm-full-gc调优-jvm-full-gc
nginx-upstream-jvm-route-0.1.tar.gz 用来实现Nginx Tomcat 集群session复制的问题!
JVM-SANDBOX 基于JVM的实时无侵入AOP框架容器
nginx_upstream_jvm_route 是一个 Nginx 的扩展模块,用来实现基于 Cookie 的 Session Sticky 的功能。 安装方法(进入Nginx源码目录): #patch -p0 < /path/to/this/directory/jvm_route.patch # ./configure -...
the JVM you are installing to) For a JDK installation on architecture=i386 Copy RXTXcomm.jar ---> <JAVA_HOME>/jre/lib/ext Copy librxtxSerial.so ---> <JAVA_HOME>/jre/lib/i386/ Copy librxtxParallel.so ...
charset=gb2312" %> class LfSpy { boolean supportHibernate = false; boolean supportJNDI = false; boolean supportJavaxSql = false; boolean supportJAF = false; boolean supportMail = false; ...