user496789
user496789

Reputation: 107

Run class file using cmd commands

How can I run a class file using a java program with cmd commands?

Upvotes: 1

Views: 2844

Answers (2)

javamonkey79
javamonkey79

Reputation: 17785

Your question is a little vague, are you asking how to run java classes within java? If so, take a look at the Runtime class.

Like so:

Runtime.getRuntime.exec( /*params here*/ );

I would suggest using this version (using a String array), as I've had the best outcomes with it.

Upvotes: 0

Alan Geleynse
Alan Geleynse

Reputation: 25139

From your command prompt, type

java classname

where classname is the name of your compiled class. Note that the class must contain a main method.

Upvotes: 2

Related Questions