Results 1 to 5 of 5
Thread: Class Cast exception
- 02-13-2011, 07:26 PM #1
Member
- Join Date
- Feb 2011
- Posts
- 22
- Rep Power
- 0
Class Cast exception
Hi
I have two Java Projects ProjectA, ProjectB
ProjectA has a refrence to ProjectB and can call the Java classes from ProjectB.
Now , I hava created in A, a Dupplicate of a Java class which exists in B and try to
Cast the originally Object(exist in B) as follow but I get a class cast exception:
com.projectA.MyDupplicateA myAObject = (MyDupplicateA)
com.projectB.getBObjects()[0];
?
Is that a class loader Problem?
Is that possible avoid this cast exception without changing the desgin of ProjectA, f.i. removing MyDupplicateA and cast again with the same ObjectB from ProjectB)?
Thanks for your help
- 02-13-2011, 08:15 PM #2
Member
- Join Date
- Feb 2011
- Posts
- 30
- Rep Power
- 0
Two classes with the same definitions but in two projects / jars will never be the same class. Remove one of them.
- 02-14-2011, 08:57 AM #3
Member
- Join Date
- Feb 2011
- Posts
- 22
- Rep Power
- 0
Hi
Thanks, but, my MyDupplicateA extends the Same Objects and same Interface from ProjectB,as the MyDupplicateB extends and implements
MyDupplicateA extends probjectB.Objectx implments projectB.xxInterface
projectB.MyObjectB extends probjectB.Objectx implments projectB.xxInterface
??Last edited by henry123; 02-14-2011 at 09:05 AM.
- 02-14-2011, 09:46 AM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,427
- Blog Entries
- 7
- Rep Power
- 17
- 02-15-2011, 11:42 AM #5
Member
- Join Date
- Feb 2011
- Posts
- 22
- Rep Power
- 0
Similar Threads
-
Need Help with Class Cast Exception
By soxfan714 in forum New To JavaReplies: 2Last Post: 11-03-2011, 04:33 PM -
Convert Vector to Generic Array Cast Exception
By officialhopsof in forum New To JavaReplies: 3Last Post: 01-04-2011, 03:49 AM -
Cast own class to FrameView
By Luxpsycho in forum AWT / SwingReplies: 0Last Post: 07-16-2010, 10:13 AM -
Menu Type cast Exception
By arulmozs in forum AWT / SwingReplies: 8Last Post: 11-02-2009, 10:34 PM -
class cast exception
By venkatallu in forum New To JavaReplies: 2Last Post: 09-02-2008, 09:50 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks