Class Cast exception
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)
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
Two classes with the same definitions but in two projects / jars will never be the same class. Remove one of them.
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
The classes String and InputStream both extend class Object directly; that doesn't make them assignable to eachother.
Originally Posted by henry123
I understood now my mistake, thanks!