First of all, a pipe connects two processes, not files (including text files), such that the output of one goes to the input of the other. The presumption is that the process "generating" the output sends it to
STDOUT, which becomes the source for the pipe, and that the process "receiving" the input reads it from
STDIN, which becomes the destination of the pipe. You cannot connect a pipe to a text file, or any other file, only to processes.
Second, when using a pipe the process on the left side of the pipe is the one that uses
STDOUT, and the process on the right side of the pipe uses
STDIN. Therefore, your attempted command would be trying to send the output of
my_program to the pipe, not reading from it.
If you properly presented the instructions you were given, then it can't work anyway. The instructions ends with "... a working program takes test cases from the input file." If the program takes input from a file, then it is not reading from
STDIN, and would ignore the data from the pipe anyway.
To make it work with a pipe,
my_program has to be written to read from the
STDIN, as in expecting you to type the test cases by hand at a prompt. Then you could rewrite the command line as
cat text_cases.txt | jave my_program
cat is a process that will read the text file and send its contents to
my_program would "read" the data from
STDIN using the pipe instead of you typing it manually. Since I don't know how java connects with pipes, this is based on the presumption that it will behave in a standard way, since the instructor asked you to use that method.
IMHO it would be better, as in less resource usage, to use redirection than a pipe.
java my_program < test_cases.txt
That is, unless this is one step that will be included in a larger chain of processes later in the course where using a pipe will become necessary.