• Post Reply Bookmark Topic Watch Topic
  • New Topic

Using classloader in abstract class  RSS feed

 
Jisha George
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am a little confused here with classloader.

I want to use a classloader in an abstract class to load a properties file.

I can do the same in a normal class.

Can somebody throw some light on this.

Thanks!
 
Barry Andrews
Ranch Hand
Posts: 529
C++ Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First, can you throw some light on what you are trying to do? You cannot instantiate an abstract class. What errors are you getting? Compile or runtime errors? What specifically is the problem?


Barry
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My guess is that the properties file is in the same directory as the abstract class, but he's using getClass() to get a Class on which to call getResource(), which will return the concrete class's Class object, which would cause the loader to look near the concrete class file instead.

If you're using getClass(), don't do that. Use "AbstractClassName.class".
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!