Hello guys , I'll start with my code:

package testapplication;

import java.util.HashMap;

public class Main {
    /** Creates a new instance of Main */
    public Main() {
     * @param args the command line arguments
    public static void main(String[] args) {
        // TODO code application logic here
        try {
            Class myClass = Class.forName("testapplication.MyFactory");
            HashMap<Class,Class> daomap = new HashMap<Class,Class>();
            Class interfaceClass = Class.forName("testapplication.LorryDAO");
            daomap.put(interfaceClass, interfaceClass);
            //create a new instance of the interface
            DAO dao;
            dao = (DAO)daomap.get(interfaceClass).newInstance();
            LorryDAO myDao = (LorryDAO) dao;
        } catch (Exception ex) {


package testapplication;

public class DAO {
    /** Creates a new instance of DAO */
    public DAO() {
    public void myDAO() {}


import testapplication.DAO;

public class LorryDAO extends DAO{
    /** Creates a new instance of LorryDAO */
    public LorryDAO() {
    public void getXXXXX() {}

Now then lets try and explain what I'm trying to acheive here. I've got a interface which for now its the concrete class, and I'm wanting to load that into my factory or in this case main.

Its ment to get the abstract DAO and then im trying to cast it to the correct class. But once the application has ran im getting the following error.... No exception is thrown. Can anyone help me out here?

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]

9 Years
Discussion Span
Last Post by ~s.o.s~

it would appear that putting System.exit(0) onto the end of main fixes the bug... is this a java bug then?

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.