Dynamic declaration of new type of object?

I am in the process of designing a arcade gallery, of which one of the features manages and loads other games into the gallery, CLASS files. Here is the scenario:

1. User wants to import a Tic Tac Toe Java game (CLASS file) he has downloaded and wants to add it to the gallery (assuming the game follows the proper arcade gallery convention).

2. User opens item on menu in the gallery program to select the TicTacToe.class file on his computer to import.

3. Gallery program writes information about this game into a configuration file, including the name of the class, TicTacToe.

4. When the gallery is started, it loads a list of games from this configuration file. In this configuration file is the name of the class file for TicTacToe. It reads this class name and stores it as a string into the gallery program memory.

5. PROBLEM: The program has the name of the class type stored as string, but how does it call this class and create an object based on this string? For example:

// Invalid code.

// Value of myString is a class name, like int or Scanner.

myString ="ClassName";

myString myNewObject =new myString();

myNewObject.someMethod();

...

Hopefully you can understand what I'm trying to do. Is there anyway to workaround this even if it requires an entirely different approach?

Thanks!

[1509 byte] By [skier55da] at [2007-10-2 5:36:52]
# 1
I'm not sure but Class.forName() method might help you.
bill180282a at 2007-7-16 1:47:23 > top of Java-index,Other Topics,Patterns & OO Design...
# 2
What you want to do is called reflection. Look into that and look at the java.lang.reflect package. Here's a tutorial on it. http://java.sun.com/docs/books/tutorial/reflect/index.html
kablaira at 2007-7-16 1:47:23 > top of Java-index,Other Topics,Patterns & OO Design...