Forum Stats

  • 3,837,681 Users
  • 2,262,285 Discussions


Cannot pass arguments to an exe file from Java

794113 Member Posts: 191
Hi, I need to run an exe file from Java. The exe runs but I am not able to provide an essential parameter to the exe.

String[] cmd = { "Dir1/the-exe-file","-param1", "<", "text-file.txt"};
Process pr = rt.exec(cmd);

It takes the first argument with no problems. But cannot take the "<" argument. The exe gives error.
In windows command prompt I need to specify that angular bracket as the next parameter is
the input file to the exe.

Do I need to escape it? or what is a solution to this problem?


Edited by: kooldba on Feb 12, 2012 2:25 PM

Edited by: kooldba on Feb 12, 2012 2:26 PM

Best Answer

  • EJP
    EJP Member Posts: 32,920 Gold Crown
    edited Feb 12, 2012 7:40PM Answer ✓
    You need to specify cmd.exe /c as the first two arguments, then everything you have now. '&lt;' isn't a general command-line argument, it is only understood by the shell.


This discussion has been closed.