3

I made a new process, but it never finishes. I was trying with ProcessBuilder and Runtime but none of it worked, both got stuck.

Builder code:

ProcessBuilder a = new ProcessBuilder(
    "java",
    "-classpath",
    "D:\\TAP",
    "AnalizadorLexico",
    "<",
    "D:\\TAP\\Lol1.txt");
Process process=a.start();

Runtime code:

Process process=cmd.exec(
    "java -classpath D:\\TAP AnalizadorLexico < D:\\TAP\\Lol1.txt ");

The command works in Windows CMD.

Greg
  • 8,917
  • 6
  • 47
  • 90

1 Answers1

0

From comments:

The "<" works with cmd(or other shells). Java program does not interpret it as input. You can use "cmd /c java progr < input ", but that makes it windows specific.

A better way will be to use real Java APIs for it: See ProcessBuilder

Once you get past this , please check another FAQ item on this

Community
  • 1
  • 1
Jayan
  • 17,353
  • 13
  • 86
  • 137