Get all classes with a specific annotation

Hey, I would like to get all the classes having an annotation named: "Command". Make sure not to have indicated the "commands" package if possible. My project would be to make a kind of commandHandler which will load all the commands in a map.

  • @ Command
    @Retention(RetentionPolicy.RUNTIME)
    @Target(ElementType.TYPE)
    public @interface Command {
      String name();
    }
  • Command Help```java@Command(name = "help")public class HelpCommand implements CommandRunner { @Override public void run(ArgumentParser parser, Subparsers subparsers) { parser.printHelp(); }}```
Was this page helpful?