• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Jj Roberts
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Himai Minh
  • Carey Brown
  • salvin francis

2 jar files with same package and same class name

 
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
 
Author and all-around good cowpoke
Posts: 13078
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
 
Paper jam tastes about as you would expect. Try some on this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic