adsense

Hii, welcome to my site. My name is Om prakash kartik. This blog helps you to learn programming languages concepts.

Compile and Run java program using batch script



How to write a batch file to Compile and run java program file



Step  1: Open any text editor to write batch script file

Step  2: Write given code your text editor or copy paste

@echo off
color a
title Programming.OM
:begin
echo :::::::::::::::::::: Welcome to Java Application ::::::::::::::::::::
echo.
Directory Name (Ex.: e:, d:)
cd Folder Name
echo Press 1. to compile java program.
echo Press 2. to run java.
echo Press 3. to Exit.
set /p a=Enter your choice number :-
if %a%==1 ( goto compile ) 
if %a%==2 ( goto Run )
if %a% equ 3 ( goto quiet )
if %a% GTR 3 ( echo Wrong choice number. 
goto begin )
:compile
set /p  file=Enter java file name with extension :-
javac %file%
 set /p ans=Do you want to compile Again (y/n):-
 if %ans%==y ( goto  compile )
 goto  begin
 
:Run
set /p file1=Enter java file name without extension :- 
java %file1%
goto begin

:quiet
echo.
echo.
echo ::::::::::::::::::::::::::::: End Application :::::::::::::::::::::::::::
pause


 Only changes some line in above code

Step 3: Change Directory Name 
             Write name of Directory where you have create java folder.
              Example :
                               e:  ,  d:
Step 4: Change Folder Name 
              Write name of Folder where you save java program file.

Step 5: Save file and provide any file name of your choice but file extension must be .bat

Step 6: Open batch file and Compile and run java program.


See Given Video 
 
Java Programs are coming soon in programming.OM

Post a Comment

0 Comments