These Program describes How to read /modify a private variable using java reflection
import java.lang.reflect.Field; class SimpleKeyPair { private String privateKey = "Sam "; // private field } public class PrivateMemberAccessTest { public static void main(String[] args) throws Exception { SimpleKeyPair keyPair = new SimpleKeyPair(); Class c = keyPair.getClass(); // get the reflected object Field field = c.getDeclaredField("privateKey"); // set accessible true field.setAccessible(true); System.out.println("Value of privateKey: " + field.get(keyPair)); // prints "Sachin " // modify the member varaible field.set(keyPair, "Sam"); System.out.println("Value of privateKey: " + field.get(keyPair)); // prints "sachin" } }