eclipse - How to run several .txt input files as a test for Java program with output files -
i've been using cmd run supplied .txt through java homework because instructor supplies correct output, can check our program functions properly. looks when it...
...documents\cse205\assignment5>java assignment5 < input1.txt > myoutput1.txt the instructor pointed file compare tool highlight differences between myoutput , expected output. learned can compile classes in folder command javac *.java
so i'd know if there way feed program each of 4 inputs 4 separate myoutput files through command prompt or other way.
thanks in advance macncheese
create file run.bat in assignment5 folder. edit (right-click -> edit...) , write this:
java assignment5 < input1.txt > myoutput1.txt java assignment5 < input2.txt > myoutput2.txt java assignment5 < input3.txt > myoutput3.txt ... make sure file names correct , assignment5 reflects name of mainclass.
then open command line (depending on windows version might differ little bit), pressing windows + r (opens run...) , typing cmd. navigate folder (cd c:\users\user3277465\documents\cse205\assignment5) should know.
type run , hit enter. batch file should executed, without closing window. can run again , again without closing folder.
additionally maybe want add compile command (javac *.java), if add in front. 
and if want script pause, can add pause - need press key @ points.
so example run.bat be:
javac *.java pause java assignment5 < input1.txt > myoutput1.txt java assignment5 < input2.txt > myoutput2.txt java assignment5 < input3.txt > myoutput3.txt it compile files, wait key input , run program in- , outputs. pause allows interrupt batch (ctrl + c) if there compile errors without running program.
Comments
Post a Comment