java P2 < X.java
should have the same behavior as if one compiles X.java with javac, and then interpretes X.class with java.
Note, your program must take input from standard input and write to standard output (so that we can use the redirection).
A sample Main.java can be found here.
Your homework will be graded for a total of 100 marks. Of these 50 marks will be for the public testcases and 50 marks for the TAs testcases.