executing a .class file

Hi all,Can anyone help me about how to execute a ".class" file from within a java Program. Thanks in advanceRegards,Deepan
[150 byte] By [deepsinsuna] at [2007-10-3 11:32:48]
# 1
TheClass.main(theArgs);
CeciNEstPasUnProgrammeura at 2007-7-15 13:59:40 > top of Java-index,Java Essentials,Java Programming...
# 2
can you explain that in detail..
deepsinsuna at 2007-7-15 13:59:40 > top of Java-index,Java Essentials,Java Programming...
# 3
What do you mean by "execute"?
quittea at 2007-7-15 13:59:40 > top of Java-index,Java Essentials,Java Programming...
# 4
> can you explain that in detail..What didn't you understand? Just call the main method.
CeciNEstPasUnProgrammeura at 2007-7-15 13:59:40 > top of Java-index,Java Essentials,Java Programming...
# 5
want to "run" that .class file from a java program..
deepsinsuna at 2007-7-15 13:59:40 > top of Java-index,Java Essentials,Java Programming...
# 6
Then see answer #1 ...
quittea at 2007-7-15 13:59:40 > top of Java-index,Java Essentials,Java Programming...
# 7
i have a class file in "c:\sample.class" i want to class file from my program. How to achieve this? i am a newbie kindly bear with me..
deepsinsuna at 2007-7-15 13:59:40 > top of Java-index,Java Essentials,Java Programming...
# 8
i have a class file in "c:\sample.class" i want to run this class file from my program. How to achieve this? i am a newbie kindly bear with me..
deepsinsuna at 2007-7-15 13:59:40 > top of Java-index,Java Essentials,Java Programming...
# 9
Several ways ...a) Runtime.exec("java -classpath c:/ sample"); // :Pb) Make sure C:\ is in the CLASSPATH, then call sample.main(new String[] {}); from within your (other) class.
quittea at 2007-7-15 13:59:40 > top of Java-index,Java Essentials,Java Programming...
# 10

> i have a class file in "c:\sample.class" i want to

> run this class file from my program. How to achieve

> this? i am a newbie kindly bear with me..

the reason you're not getting a straightforward answer is that this is the sort of thing you can find out for yourself in the tutorials, or from your teacher, or a book, or a simple google query. the forum isn't the place for complete novices to learn from, that would be a waste of effort on everybody's part

get reading!

georgemca at 2007-7-15 13:59:40 > top of Java-index,Java Essentials,Java Programming...
# 11

> the reason you're not getting a straightforward

> answer is that this is the sort of thing you can find

> out for yourself in the tutorials, or from your

> teacher, or a book, or a simple google query.

... or because it's hard to understand why you'd want to do what you asked for.

quittea at 2007-7-15 13:59:40 > top of Java-index,Java Essentials,Java Programming...
# 12
thanks for the replies..
deepsinsuna at 2007-7-15 13:59:40 > top of Java-index,Java Essentials,Java Programming...
# 13

> > the reason you're not getting a straightforward

> > answer is that this is the sort of thing you can

> find

> > out for yourself in the tutorials, or from your

> > teacher, or a book, or a simple google query.

>

> ... or because it's hard to understand why you'd want

> to do what you asked for.

you've never had to invoke methods in one class, from another class?

georgemca at 2007-7-15 13:59:40 > top of Java-index,Java Essentials,Java Programming...
# 14
> you've never had to invoke methods in one class, from another class?No <:)P.S.: Of course, but calling "main" on another class looks like a design flaw to me.
quittea at 2007-7-15 13:59:40 > top of Java-index,Java Essentials,Java Programming...
# 15

> > you've never had to invoke methods in one class,

> from another class?

>

> No <:)

presumably all your logic is inside one Main method, and doesn't involve any objects at all then :)

>

> P.S.: Of course, but calling "main" on another class

> looks like a design flaw to me.

well, in all fairness, the OP never asked that. Rene merely suggested it

georgemca at 2007-7-21 13:55:53 > top of Java-index,Java Essentials,Java Programming...
# 16

> > No <:)

>

> presumably all your logic is inside one Main method,

> and doesn't involve any objects at all then :)

Sure. OOP is for girls ...

> > P.S.: Of course, but calling "main" on another class

> > looks like a design flaw to me.

>

> well, in all fairness, the OP never asked that. Rene

> merely suggested it

That's why I dared to ask the OP, see reply #5. It's highly probable the OP wants to do something similar.

quittea at 2007-7-21 13:55:53 > top of Java-index,Java Essentials,Java Programming...