How do I refer to Java 1.6 APIs while degrading gracefully against Java 1.5?
问题 I would like to use the java.text.Normalizer class from Java 1.6 to do Unicode normalization, but my code has to be able to run on Java 1.5. I don't mind if the code running on 1.5 doesn't do normalization, but I don't want it to give NoClassDefFoundError s or ClassNotFoundException s when it runs. What's the best way to achieve this? 回答1: The usual way of doing this is via reflection, i.e. don't refer directly to the class in question, but invoke it programmatically. This allows you to catch