Search code examples
javaiojavawconsole-input

What happens when I use javaw to run the java program in the following scenario?


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?


Solution

  • 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