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 6728271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:09:01+00:00 2026-05-26T10:09:01+00:00

I have basic knowledge of Java’s reflection API – therefore, this is not only

  • 0

I have basic knowledge of Java’s reflection API – therefore, this is not only a question of how, it’s a question of whether it’s possible and whether I’m going about a solution the best way.

We’re doing some acceptance testing of multiple, interrelated projects; each of these projects retrieve data from a MongoDB store using an in-house abstraction API. To facilitate this testing, each component needs some pre-loaded data to be available in the database.

I’m building a command-line tool to accept a DTO (pre-compiled class binary), for loading of multiple instances using the morphia ORM library. I would like each member of our team to be able to run the generator passing in via cli their DTO (in jar or directory form), and a file (csv or otherwise) for instantiating a desired amount of records.

I have the class loading working fine with URLClassLoader. Now I’m trying to instantiate an instance of this class using data from a file.

Is this possible? Would serialized objects be a better approach?

  • 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-05-26T10:09:02+00:00Added an answer on May 26, 2026 at 10:09 am

    That’s perfectly possible using the Java Reflection API :

    • Load Class instance by name (Class.forName(className), you don’t really need the ClassLoader instance)
    • Grab Constructor instance of constructors have parameters and invoke newInstance(Object… args) on this constructor instance to create an instance of your DTO class.
    • Invoke getDeclaredFields() on your Class instance and iterate over them to set their values (field.set(instance, value)). Make sure to invoke field.setAccessible(true) to be able to access private fields.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have only a basic knowledge of css, is it possible to inherit a
I have very little programming knowledge; only a fair bit in Visual Basic. How
I only have very basic knowledge on Javascript and I want to be able
I have a basic question on Java ArrayList . When ArrayList is declared and
[Yes I have seen this question but I do not know C nor C++,
I have basic knowledge of Java and some experience with MVC pattern. I have
I'm new with C#, I have some basic knowledge in Java but I can't
I have a very basic knowledge of the web programming, and I couldn't figure
I have some knowledge about Human computer interaction and some basic knowledge programming scripts
My knowledge of xml and php is somewhat basic but have been able to

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.