Forum Stats

  • 3,750,519 Users
  • 2,250,187 Discussions
  • 7,866,997 Comments

Discussions

Cannot pass arguments to an exe file from Java

794113
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?

Thanks

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

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

Best Answer

  • EJP
    EJP Member Posts: 32,920 Gold Crown
    edited Feb 12, 2012 7:40PM Accepted 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.

Answers

This discussion has been closed.