Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8430199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:32:36+00:00 2026-06-10T05:32:36+00:00

I know there are incredible set of tools for loading plugin classes in java,

  • 0

I know there are incredible set of tools for loading plugin classes in java, but today an idea came to my mind.

What if I have a bunch of annotated and un-annotated classes in package “org.home.junk” (annotated with annotation “@AnnotatedClass”) and those classes have annotated methods with say annotation “@AnnotatedMethod”.

First question: can I at run-time get an array/collection of all the classes in that specific package, so that I could check which one’s are annotated and create an instance of them. (I am aware however how to check if Some.class has annotations courtesy of this guide: http://isagoksu.com/2009/development/java/creating-custom-annotations-and-making-use-of-them/)

Second question: – If I can do what I’d like in first question – what would be the most political way to do this?

I believe it is possible, as I understand JUnit loads test-case classes in some similar manner.

Also it would be cool if this could be done with minimal third party libraries and such, again – if it’s possible 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T05:32:37+00:00Added an answer on June 10, 2026 at 5:32 am

    First answer: Take a look at this project.

    Reflections reflections = new Reflections("org.home.junk");
    Set<Class<?>> annotated = reflections.getTypesAnnotatedWith(javax.persistence.Entity.class);
    

    It returns all the classes from org.home.junk annotated with javax.persistence.Entity annotation.

    Second Answer: To create new instance of above classes you can do this

    for (Class<?> clazz : annotated) {
        final Object newInstance = clazz.newInstance();
    }
    

    Hope this answers everything.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know there have been many questions on grid and pack in the past
I know there are lots of tools on the net that can make our
I know there is a lot on this topic but I can't get any
I know there are a lot of similar questions on SF, but I think
I know there is a wiki page about it , but since I'm very
I know there are a lot of questions around on this subject, but I've
I know there is a function called ISDATE to validate DATETIME columns, but it
Does anyone know if there is a php library, or if there isnt, have
i know this is incredibly easy but I have been writing and rewriting this
I know there are a few workarounds to create an always visible bottom menu

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.