import java.awt.Color; import java.lang.reflect.Field; public class Main { public static void main(String[] argv) throws Exception { System.out.println(getColor("blue")); } public static Color getColor(String colorName) { try { Field field = Class.forName("java.awt.Color").getField(colorName); return (Color) field.get(null); } catch (Exception e) { return null; } } }