Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

dynamically loading a class  RSS feed

 
ralph roper
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a way to pass constructor parameters when dynamically loading a class ? ie Class.forName()
The class I am trying to load is related to a database table. Does anyone know if using JDO is a better alternative to dynamically loading a class ? (.. or am I completely off the track here
?)
 
Steve Deadsea
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use the Class.getConstructor(Class[] parameterTypes) method and then get a new instance from that Constructor using Constructor.newInstance(Object[] initargs)
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!