Execute batch file with args in java
<p>I am trying to run batch file using java command.
I have following code</p>

<pre><code>Runtime.getRuntime().exec("cmd /c start C:\\temp\\Sept_2016\\22Sept\\filecompare.bat");
</code></pre>

<p>I have batch file named filecompare.bat as below</p>

<pre><code>fc "C:\temp\Sept_2016\22Sept\MSP_Files\msp.txt" "C:\temp\Sept_2016\22Sept\MIB_Files\mib.txt"&gt;&gt;"C:\temp\Sept_2016\22Sept\mismatch.txt"
</code></pre>

<p>This works as per expected and output gets stored in txt file.</p>

<p>Now I don't want to use hard coded values as above I want to get the values from Java program. So I am writing java code as below</p>

<pre><code>String file1 = new String("C:\\temp\\Sept_2016\\22Sept\\MSP_Files\\msp.txt");
String file2 = new String("C:\\temp\\Sept_2016\\22Sept\\MIB_Files\\mib.txt");
String file3 = new String("C:\\temp\\Sept_2016\\22Sept\\mismatch.txt");
Runtime.getRuntime().exec(new String[]{"cmd.exe", "/c", "start C:\\temp\\Sept_2016\\22Sept\\filecompare.bat", file1, file2, file3}); 
</code></pre>

<p>On the similar lines I am modifying batch file as </p>

<pre><code>fc %4 %5&gt;&gt;%6
</code></pre>

<p>But this does not seem to be working. It is just opening dos window.</p>

<p>Could you please help me achieve this?
Thanks in advance</p>