1

Say suppose I am running a java program through command line. And this program requires some data to enter during the execution. So I was wondering on what happens if somebody uses javaw to run this type of program?

That is how to enter the data to the program?

Toon Krijthe
  • 52,876
  • 38
  • 145
  • 202
GuruKulki
  • 25,776
  • 50
  • 140
  • 201

2 Answers2

2

You can't get interactive input, but if you wanted to read from a file, you could, or you could redirect standard input to a file or pipe.

cat myText.txt | javaw myJavaClass

or Windows

type myText.txt | javaw myjavaClass
Stefan Kendall
  • 66,414
  • 68
  • 253
  • 406
0

You can't. Since javaw doesn't allocate a console you have no way of entering data.

Joey
  • 344,408
  • 85
  • 689
  • 683
  • Could you not redirect standard in to a file, or similar? – Stefan Kendall Mar 18 '10 at 19:48
  • @Stefan: You simply won't have the stdin, stdout and stderr streams. Those only exist for console applications. So no, redirection very likely won't work. – Joey Mar 18 '10 at 20:29