Load a class inside class?

Hi all!

I am creating a console based program and I wonder how i can load an outside class inside my main class?

I have a case switch funktion and when you chosse case '3' i want the class to run another class file and the continute with the rest of the code in the main class file.

Is there a way to do this?

[336 byte] By [SAJBERa] at [2007-10-1 8:28:54]
# 1
use a class loader
Kronik_Orpheusa at 2007-7-9 22:32:05 > top of Java-index,Desktop,I18N...
# 2
It depends on the class you wish to load.You can use Class.forName("MyClass") which looks to the "current" ClassLoader tofind a class corresponding to the name you give it.Or you can even specify a ClassLoader in the forName method.
killerCodingNinjaMonkeya at 2007-7-9 22:32:05 > top of Java-index,Desktop,I18N...
# 3

It really depends on what you mean by "run another class file". Do you mean you want to execute its static main() method, just as if it were run from the command line? If so then just do this:String[] params = // the parameters you want to pass to the class

TheClass.main(params);

DrClapa at 2007-7-9 22:32:05 > top of Java-index,Desktop,I18N...
# 4
simply create the instance of the outside class in 3 case of switch case.. and continuew with ur code
sampathnka at 2007-7-9 22:32:05 > top of Java-index,Desktop,I18N...
# 5
> simply create the instance of the outside class in 3> case of switch case.. and continuew with ur codeIf it were always that easy...
RichardTheLionHearteda at 2007-7-9 22:32:05 > top of Java-index,Desktop,I18N...