ERROR:JDWP Unable to get JNI 1.2 environment ,jvm-> GetEvn() return =-2
Posted on 2008-04-13 23:01 Robert Su 閱讀(3989) 評論(7) 編輯 收藏ERROR:JDWP Unable to get JNI 1.2 environment ,jvm-> GetEvn() return =-2
原因:tomcat-eclipse-plugin插件啟動報(bào)錯
原因:JDK版本問題
原因:tomcat-eclipse-plugin插件啟動報(bào)錯
ERROR:JDWP Unable to get JNI 1.2 environment ,jvm-> GetEvn() return =-2
原因:JDK版本問題
查閱Java Doc,發(fā)現(xiàn)其中有這么一段話:
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..."
翻譯一下:
虛
擬機(jī)是否有一個控制臺Console取決于所依賴的平臺和虛擬機(jī)解析該方法的方式。如果虛擬機(jī)是從一個交互式的命令行中啟動的,而沒有重定向標(biāo)準(zhǔn)輸入和輸
出流,那么虛擬機(jī)會自動的連接到鍵盤作為標(biāo)準(zhǔn)輸入,并且把啟動虛擬機(jī)的地方作為標(biāo)準(zhǔn)輸出。如果虛擬機(jī)是自動啟動的,例如通過后臺的一個任務(wù)計(jì)劃,那么典型
的情況就是沒有Console控制臺......。
于是,思考一下我們運(yùn)行上面程序的地點(diǎn)——Eclipse等集成開發(fā)環(huán)境,這對于上面描述中的把啟動虛擬機(jī)的地方作為標(biāo)準(zhǔn)輸出來說是不合適的,這里的Console()返回的默認(rèn)情況下是Null,于是就產(chǎn)生了上面的出錯信息。(也許未來Eclipse會有所改進(jìn)吧)
怎么解決該問題呢?這里提供兩條思路給大家(已經(jīng)實(shí)際操作過,可以實(shí)現(xiàn)功能的正常運(yùn)作)
1、使用命令行進(jìn)行運(yùn)行,編譯可以使用集成開發(fā)環(huán)境。這樣可以完成標(biāo)準(zhǔn)輸出。
2、在程序中重定向標(biāo)準(zhǔn)輸出到其他的設(shè)備或者方式(例如寫到文本文件),這樣也可以"比較不方便的"完成該功能。