How to get Class Name given along with java.exe

Hi friends,

I am Mukesh, currently facing one problem

On command prompt to execute any java program we give :

C : \.-- > java ClassName

This ClassName I need in my application, I want to do some post processing on that.

Actually see what I want :

public class Base

{

static Base object;

public static void main(String[] args) throws Exception

{

object=(Base)Class.forName("Derived Class Name").newInstance();

object.main();

}

void main()

{

}

}

public class Derived extends Base

{

void main()

{

System.out.println("Hello World");

}

}

I am trying to Run Derived Class, since there is no entry point found, default JVM invoke the Base class's entry point, there I want to load

Derived Class, but I am not getting any identity of derived class in Base class.

I found one temporary solution to this problem :

C: \ -- >java Derived Derived

& in Base class, I have loaded class

object=Class.forName(args[0]).newInstance();

But I dont want to write the same thing twise just to know the Class name which is given along with java.exe.

Is there any way to get the ClassName supplied with java.exe

I have tried a lot, still I am trying !!!

If any one knows the answer, help me.

Regards.

Mukesh.

[1411 byte] By [Mukesh.Bhojwania] at [2007-11-27 11:09:40]
# 1

But it's your class... ?

cotton.ma at 2007-7-29 13:36:56 > top of Java-index,Java Essentials,Java Programming...
# 2

yes it's my class ......

do you have any idea !!!

Mukesh.Bhojwania at 2007-7-29 13:36:56 > top of Java-index,Java Essentials,Java Programming...
# 3

> yes it's my class ......

>

>

> do you have any idea !!!

Well for one thing you cannot over-ride static methods.

cotton.ma at 2007-7-29 13:36:56 > top of Java-index,Java Essentials,Java Programming...
# 4

There is no static overridding here,

There is no public static void main in derived class,

I am trying to derive void main() method from Base to Derive,

& Base in it's public static main invoke void main on object instance of any of it's derived class

Mukesh.Bhojwania at 2007-7-29 13:36:56 > top of Java-index,Java Essentials,Java Programming...