The file which is having (anynameXXX).bat extension then these files are called Windows Batch files.
In this batch file we can write all the commands that we generally use in Command Prompt.
one sample java example with sequence of steps are shown below.
1)create a java class as shown below,
WindowsBatchFileUsage.java
-------------------------------------------
public class WindowsBatchFileUsage {
public static void main( String argv[] ) throws Exception {
System.out.println("MyBatch.bat Batch File executed successfully");
}
}
2)Now i don't want to open my command prompt for compile and execute this java class.
i write a batch file(MyBacth.bat),that contains all the commands to compile and execute my java class.
create a file with extension of .bat ,Right click edit that file and write following commands and save.
MyBatch.bat
---------------------------------
javac *.java
java WindowsBatchFileUsage
pause
3)Now double click that batch file(MyBatch.bat)
it opens command prompt and executes all the commands that we write in batch file.
No comments:
Post a Comment