ERROR: JDWP Unable to get JNI 1.2 environment

后端 未结 6 655
野的像风
野的像风 2020-11-29 00:45

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

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


        
相关标签:
6条回答
  • 2020-11-29 01:22

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

    That's all you have to do.

    0 讨论(0)
  • 2020-11-29 01:29

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

    0 讨论(0)
  • 2020-11-29 01:30

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

    0 讨论(0)
  • 2020-11-29 01:34

    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]
    
    0 讨论(0)
  • 2020-11-29 01:44

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

    0 讨论(0)
  • 2020-11-29 01:46

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

    0 讨论(0)
提交回复
热议问题