Friday, March 13, 2009

Run java through batch file

While working with console based java compiler…its very tedious to write javac filename.java and then to run java filename each time you want to see the output.

A simpler(& very simpler) 'fix' to this is to create a batch file with parameters:
1) Goto Start - run - "cmd"(enter)
2) c:\>Documents and Settings\(ur employee ID)> (Now if u want to store your .java files here then skip goto step 5)
3) c:\>Documents and Settings\(ur employee ID)> copy con s.bat (enter)
cd\
e:
cd
(press Ctrl+Z) to save the file.
4) c:\>Documents and Settings\(ur employee ID)> s (enter)
5) e:\>(foldername)> copy con j.bat (enter)
javac %1.java
java %1
(press Ctrl+Z) to save the file.
And there u go. Each time you want to runa .java file again….
just follow the below steps:

1)Goto cmd - s(enter)
e:\>(foldername)> j filename (enter)
The file runs. Very simple….and yet effective!!!

No comments:

Computers Add to Technorati Favorites Programming Blogs - BlogCatalog Blog Directory