Thanks Matt. If you have it handy, I'd be interested to see the additional code needed to pass arguments to the constructor. If it's a hassle then don't worry about it.
Overall, is this a common approach in Java, or is dynamic instantiation frowned upon? -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Matt Liotta Sent: Monday, May 10, 2004 10:14 AM To: [EMAIL PROTECTED] Subject: Re: [CFCDev] OT: Dynamic class instantiation in Java? Class clazz = Class.forName("package.ClassName"); clazz.newInstance(); If you want to actually pass parameters to the constructor then there is a whole lot more code needed. Matt Liotta R337 Consulting LLC http://r337.com On May 10, 2004, at 10:06 AM, Brian Kotek wrote: > Off topic but I thought someone here might know the answer. Is it > possible to dynamically instantiate a class in Java? Similar to how > you > could do: > > <cfset myObjVar = "someComponent" /> > <cfset myObj = createObject( 'component', '#myObjVar#' ) /> > > In other words, to instantiate a class in Java when you won't know > until > runtime what class you want to instantiate? > > > Thanks, > > Brian > > ---------------------------------------------------------- > You are subscribed to cfcdev. To unsubscribe, send an email > to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' > in the message of the email. > > CFCDev is run by CFCZone (www.cfczone.org) and supported > by Mindtool, Corporation (www.mindtool.com). > > An archive of the CFCDev list is available at > www.mail-archive.com/[EMAIL PROTECTED] > ---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' in the message of the email. CFCDev is run by CFCZone (www.cfczone.org) and supported by Mindtool, Corporation (www.mindtool.com). An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED] ---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' in the message of the email. CFCDev is run by CFCZone (www.cfczone.org) and supported by Mindtool, Corporation (www.mindtool.com). An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]
