You can make your program stop executing at that point. For example:
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String str = in.nextLine();
if (str.equals("HELLO")) {
System.out.println("Compile Error: " + str);
System.exit(1);
}
// Do something else.
}
}
Another way to do it is to throw an exception ... except than you will get an exception stacktrace as well as a message. In the context you are doing this, it probably doesn't matter.
Note that there are some potential problems with this:
If the judge intercepts all output, then it may not be possible to get hold of the messages that your application produces.
The judge may feed your application different inputs each time it judges it.
However, this is not a real compile error. Indeed, it doesn't make sense for your program to generate a real compile error.
Compile errors occur when code is being compiled, and they are output by the compiler. But a Java application cannot read input (from the user or the "judge") at compile time. It can read input at runtime ... but then it is too late for a compilation error.
You seem to have your terminology confused. I suggest you read these articles to understand what the various terms mean:
Your commented thus:
Think that you are given a program that you don't know what it should do and it pass some tests on an online judge. You know what the input could be but don't know in which order they come and you should get the test cases without actually accessing the online judge's test cases. I want to make my program give me some errors to find out what is in each test case.
and
I just have a working program and want to extract the input from online judge.
That is not a compilation error you are talking about. That is a runtime error, because you want / need it to happen when your program runs. Please refer to the links above for explanations of these terms.