How to make Batch (.bat extension) File

To run your java program by just double clicking, you have to create a .bat file. This .bat file will be used to run your java code. Your click will first compile it, then run it automatically.



Method to create .bat extension file for your java code is as follows:

1. First create a notepad file.
2. Write  >>>       javac ClassName.java
3. If you have more than one then FirstClassName.java
    2ndClssName.java  3rdClassName.java & so on.
4. Press Enter Key & go to next line.
5. Write java MainClassName
6. Save it.
7. Change extension of notepad file to .bat
8. Click .bat file e.g. notepad.bat, it will run your java code.

No comments:

Post a Comment