🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.lang.java.help
3 messages
3 total messages Started by Brent Peckover Sat, 20 Mar 1999 00:00
Dynamically load and instantiate unknown classes at runtime.
#77
Author: Brent Peckover
Date: Sat, 20 Mar 1999 00:00
11 lines
1292 bytes
I'm trying to create an application which will allow itself to be
extended without requiring the original code.  Information comes into a
control thread, and is then synchronously passed to a list of classes
which are not know at design time.

How do I tell Java to Load a class (say I get the required class name
out of a text file at runtime), create an instance of the class, and
then call the new instance's methods (which may also be listed in the
file)?

Anyone have any suggestions?
Re: Dynamically load and instantiate unknown classes at runtime.
#78
Author: Matt the Rat
Date: Sat, 20 Mar 1999 00:00
13 lines
1100 bytes
Brent Peckover wrote in message <36F3DDDE.2FF6DBD4@archiveware.net>...
>How do I tell Java to Load a class (say I get the required class name
>out of a text file at runtime), create an instance of the class, and
>then call the new instance's methods (which may also be listed in the
>file)?


Look at the java.lang.reflect package and the Class class, in particular
Class.forName and Class.newInstance.

--
Matt the Rat
Reply to matt DOT helliwell AT net DOT ntl DOT com
Re: Dynamically load and instantiate unknown classes at runtime.
#76
Author: Iain Lowe
Date: Mon, 22 Mar 1999 00:00
27 lines
1670 bytes

Brent Peckover wrote:
> 
> I'm trying to create an application which will allow itself to be
> extended without requiring the original code.  Information comes into a
> control thread, and is then synchronously passed to a list of classes
> which are not know at design time.
> 
> How do I tell Java to Load a class (say I get the required class name
> out of a text file at runtime), create an instance of the class, and
> then call the new instance's methods (which may also be listed in the
> file)?
> 
> Anyone have any suggestions?

JavaWorld's Bill Venners has looked at both reflection (runtime class
info) _and_ dynamic extension in columns. You can check them out here :

Design with runtime class information -
http://www.javaworld.com/javaworld/jw-02-1999/jw-02-techniques.html
Design with dynamic extension -
http://www.javaworld.com/javaworld/jw-01-1999/jw-01-techniques.html

Hope this helps =)

Iain Lowe
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads