Consider the following code: A.java: import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @Retention(RetentionPolicy.RUNTIME) @interface A{} C.java: import java.util.*; @A public class C { public static void main(String[] args){ System.out.println(Arrays.toString(C.class.getAnnotations())); } } Compiling and running works as expected: $ javac *.java $ java -cp . C [@