To find identify the deprecated methods and classes, you do what the quoted text says. You compile with the "-deprecation" switch and the offending methods/classes will be shown as compilation warning messages. (If you are using an IDE, then the deprecation warnings will be enabled / disabled some other way.)
If you are actually asking how the compiler knows that a method or class is deprecated, the answer is that a class or method is marked as deprecated by putting a "@deprecated" tag into the corresponding javadoc comment. The java compiler notes this, and sets an attribute in the bytecode file when it compiles the class. Then, when you try to use the class/method in your code, the java compiler reads the bytecodes, notes the attribute and outputs the warning message.
Deprecation is intended as a strong hint to the developer that the method or class in question should no longer be used. A deprecated class or method typically has some flaw in it (major or minor) that could not be fixed without breaking existing code. Rather, a non-compatible replacement has been implemented that requires you to make some changes to your source code.
In theory, deprecated classes and methods may be removed in future releases. While Sun rarely (if ever) does this, third-party library developers are more willing to remove deprecated methods when cleaning up their APIs.