aspose file tools*
The moose likes Java in General and the fly likes 2 jar files with same package and same class name Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "2 jar files with same package and same class name" Watch "2 jar files with same package and same class name" New topic
Author

2 jar files with same package and same class name

shobhit garg
Ranch Hand

Joined: Mar 07, 2004
Posts: 42
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

Joined: Mar 22, 2000
Posts: 12835
    
    5
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: 2 jar files with same package and same class name