# how to execute command line programe in java



## virkjay (Nov 1, 2007)

Hi guys, I am doing pass command line argument programe in java but I don't know how to run this programe. Path for this programe in my my computer is C:\Users\Desktop\Mainjava\mycode\CommandProgjava*
{code/}
public class CommandProg
{
public static void main(String[] args)
{
System.out.println("d");
for (int i = 0; i < args.length; i++)
System.out.println(args);
}

} 
{code/}
Where i need to go and what command i need to give so i can execute this programe(I am using window vista). I only know i have to give
this command some where :- CommandProg arg1 arg2 arg3 arg4. Output should be
Output:

arg1
arg2
arg3
arg4

Please help me, Thanks in advance.


----------



## Chicon (Jul 29, 2004)

If your program is compiled, you should have a file called *CommandProg.class*.
To run your program :
- open a DOS window
- at the DOS prompt, type the following command :
*java.exe -classpath C:/Users/Desktop/Mainjava/mycode CommandProg arg1 arg2 arg3 arg4*


----------



## virkjay (Nov 1, 2007)

hi, Thanks for ur help. I am using window vista, so if i put cmd in search box then a window pop up but not sure if that is dos window? If that is not Dos then how could i get dos on my computer?


----------



## Chicon (Jul 29, 2004)

To start a DOS window on Vista :
- click on the button in the left lower corner of the screen to open the menu,
- in the small pane at the bottom of the menu, type *cmd* and hit the enter key, the DOS window will open.


----------



## virkjay (Nov 1, 2007)

Thanks mate, You are star.


----------

