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]

Reply via email to