Tag Archives: ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2

ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2

What are the eight life cycle hook functions of Vue>>>

Error: jdwp unable to get JNI 1.2 environment, JVM – > GetEnv() return code = -2

eclipse 3.4+jdk1.6

The compilation passed normally, and an error occurred when running debug mode

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]

Find the cause of the error. It was found that there was a problem with redirecting the output

The following is the original web information

installed JDK1.6, ha ha ~ I have encountered this problem
this is what I found on the Internet before. I hope it can help you
ERROR:JDWPUnabletogetJNI1.2environment,jvm-> GetEnv()returncode=-2
JDWPexiterrorAGENT_ ERROR_ NO_ JNI_ Env (183): [... /./SRC/share/back/util. C: 820]

What's going on?Now Java se6 has reached the stage of RC?Sun can't have such a mistake ~ ~

after I carefully checked Javadoc, It is found that there is a passage:

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

"Whetheravirtualmachinehasaconsoleisdependentupontheunderlyingplatformandalsouponthemannerinwhichthevirtualmachineisinvoked.Ifthevirtualmachineisstartedfromaninteractivecommandlinewithoutredirectingthestandardinputandoutputstreamsthenitscons olewillexistandwilltypicallybeconnectedtothekeyboardanddisplayfromwhichthevirtualmachinewaslaunched.Ifthevirtualmachineisstartedautomatically,forexamplebyabackgroundjobscheduler,thenitwilltypicallynothaveaconsole.""> http://download.java.net/jdk6/docs/api/java/io/Con... "

Translation:

whether a virtual machine has a console depends on the platform it depends on and the way the virtual machine resolves the method. If the virtual machine is started from an interactive command line without redirecting the standard input and output streams, the virtual machine automatically connects to the keyboard as the standard input and takes the place where the virtual machine is started as the standard output. If the virtual machine is started automatically, for example, through a task plan in the background, then the typical situation is that there is no console

so think about where we run the above program & amp; mdash;& amp; mdash; Eclipse and other integrated development environments, which is not suitable for the above description of taking the place where the virtual machine is started as the standard output. The console () here returns null by default, so the above error message is generated( Maybe eclipse will improve in the future)

how to solve this problem?Here are two ideas for you (it has been actually operated and can realize the normal operation of the function)

1. Use the command line to run, and use the integrated development environment to compile. In this way, the standard output can be completed
2. Redirecting standard output to other devices or methods (such as writing to a text file) in the program can also "inconveniently" complete the function

3. At the end of main function, add system. Exit (0)