Java tutorial
//package com.java2s; import java.lang.reflect.Field; public class Main { public static Class<?> sCurrentClass; public static Object getStaticValue(String fieldName) { Field field = getField(fieldName); if (field == null) { return null; } Object result = null; try { result = field.get(null); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } return result; } private final static Field getField(String name) { Field field = null; try { field = sCurrentClass.getDeclaredField(name); field.setAccessible(true); } catch (SecurityException e) { e.printStackTrace(); } catch (NoSuchFieldException e) { // e.printStackTrace(); } return field; } }