Execute java commands through java code

Hi guys,

I want to run a java class from another class.

I tried like this..

Runtime.getRuntime("java C:\test2");But test2 did not run.

But I could execute this command sucessfully.

Runtime.getRuntime("javac C\test2.java");

I could see class file generated for this.

Please suggest me how to run a java class .....

Thanks in advance.

[387 byte] By [SecfGuya] at [2007-11-27 6:21:33]
# 1

> Hi guys,

> I want to run a java class from another class.

> I tried like this..

> Runtime.getRuntime("java C:\test2");But test2 did not

> run.

Because the JVM (the java command) does not take a file as its argument. It takes a class name. You'd want something like java -cp C:\ test2

> But I could execute this command sucessfully.

> Runtime.getRuntime("javac C\test2.java");

Because javac, unlike java, does take files (rather than a class name) as its argument.

jverda at 2007-7-12 17:38:06 > top of Java-index,Java Essentials,Java Programming...