| | |
Java Class Class problem
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Dec 2004
Posts: 489
Reputation:
Solved Threads: 5
Hello guys , I'll start with my code:
----
---
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?
Java Syntax (Toggle Plain Text)
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"); System.out.println(myClass); HashMap<Class,Class> daomap = new HashMap<Class,Class>(); //Interface //Real 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; myDao.getXXXXX(); } catch (Exception ex) { ex.printStackTrace(); } } }
Java Syntax (Toggle Plain Text)
package testapplication; public class DAO { /** Creates a new instance of DAO */ public DAO() { } public void myDAO() {} }
---
Java Syntax (Toggle Plain Text)
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]
![]() |
Similar Threads
- Class and Sub Class (Java)
- java and using observable class (Java)
- Class in a class... (Java)
- Help with class methods (Java)
- class array problem! (C++)
- My class cannot be reuse (Java)
- Basic help with Java class (Java)
- Confused writing a Java Class (Java)
Other Threads in the Java Forum
- Previous Thread: Floating numbers
- Next Thread: implemetation question regarding interfaces and classes
Views: 2460 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for Java
android api apple applet application arguments array arrays automation bidirectional binary birt bluetooth calculator chat class classes client code columns component database designadrawingapplicationusingjavajslider draw eclipse editor error errors event exception expand file fractal game givemetehcodez graphics gui guidancer helpwithhomework html ide image inetaddress input integer intellij j2me java javamicroeditionuseofmotionsensor javaprojects jme jmf jni jpanel julia link linux list loop map method methods mobile mobiledevelopmentcreatejar myaggfun netbeans newbie number object oracle plazmic print problem program programming project recursion scanner screen server set signing size smart sms smsspam socket sort sql string subclass support swing test threads time transfer tree webservices windows






