• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

2 jar files with same package and same class name

 
shobhit garg
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
I have two seperate classloaders,each loading classes from 2 seperate jar files.The problem is :
both the jar files say j1 and j2 have a packeages by same name say p with the
same class say c.
ie structure is
j1 > p > c
and j2 > p > c

can we load these jars with 2 seperate classloaders have the same parent class loader.

Because in this case i am getting a class cast exception for class p.c on launching the application with this structure.

Best Regards,
Shobhit
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13073
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because in this case i am getting a class cast exception for class p.c on launching the application with this structure.


I don't think there is any way to avoid a class cast exception if you try to assign to a reference in a class created by the parent class loader. I suspect you will have to use Java's reflection capabilities.

Maybe java.lang.reflect.Proxy will help.
Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic