This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Creating Java classes on fly  RSS feed

 
Bob Mathews
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Can any one tell me how can I create Java classes on the fly.


Like if I provide name of the java class(fully qualified), with specification of its methods and fields how can I create java classes on fly.

Do I need some Byte code engg. or I can do it with Plane reflection

Thanks
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Reflection only works on existing objects (and hence, classes). But you can construct classes from source code at runtime using a library like Javassist. This article I wrote for the JavaRanch Journal explains how it's done.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!