Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Class loader - non empty constructor ?  RSS feed

 
jay vas
Ranch Hand
Posts: 407
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi : Does anybody know how to load a class (using class.forName or
some other dynamic method) which has a non empty constructor ?
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello "JAY asasd"-

On your way in you may have missed that we have a policy on screen names here at JavaRanch. Basically, it must consist of a first name, a space, and a last name, and not be obviously fictitious. Since yours does not conform with it, please take a moment to change it, which you can do right here.

As to your question, you would use the Reflection API, which is in the java.lang.reflect package. You can still use Class.forName() to obtain a Class object, and then invoke "getConstructors()" on it. That will give you a list of all constructors. With that, you can examine which parameters they take, and call them accordingly.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!