• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

loadClass, defineClass (run-time loading)

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey!
I'm using the Reflection API

I load a class called 'SubClass' which exists in a directory called 'subdir' at run-time from my program
-------------------------------------------------------------------- ----------
CustomClassLoader loader = new CustomClassLoader();
Class classRef = loader.loadClass("SubClass");
---------------------------------------------- --------------------------------

class CustomClassLoader extends ClassLoader. I have defined 'findClass(String className)' method in CustomClassLoader.

This is what 'findClass(String className)' returns:
defineClass (className,byteArray,0,byteArray.length);

'byteArray' is of type byte[] and has the contents of subdir/SubClass.

the problem:
-----------------
The program runs fine if SubClass does not extend any class.
If however, SubClass extends another class, the program throws a NoClassDefFoundError. How does one take care of the inheritance here?

Help appreciated in advance..
Thanks!
reply
    Bookmark Topic Watch Topic
  • New Topic