Accessing static fields is similar to accessing nonstatic fields. Use the
Field functions that work almost identically to their nonstatic counterparts, with two differences:
• As you have no object, you must use
FindClass instead of
GetObjectClass to obtain the class reference.
• You have to supply the class, not the instance object, when accessing the field.
For example, here is how you can get a reference to
/* get the class */ jclass class_System = (*env)->FindClass(env, "java/lang/System"); /* get the field ID */ jfieldID id_out = (*env)->GetStaticFieldID(env, class_System, "out", "Ljava/io/PrintStream;"); /* get ...