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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T22:21:54+00:00 2026-06-08T22:21:54+00:00

I am working on a project that connects to different devices of the same

  • 0

I am working on a project that connects to different devices of the same type. I have implemented a few classes for single devices, but now developed a generic interface that all “drivers” should implement.

My Problem is now: Later, the user should use my program via GUI and should be able to “load” the drivers offered from me. But how do these drivers look like? A .jar with a class that implements the driver interface? A xml file that describes roughly what to do?

  • 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-08T22:21:55+00:00Added an answer on June 8, 2026 at 10:21 pm

    You might consider the following post as a starting point: https://stackoverflow.com/a/2575156/471129

    Basically, dependency injection and inversion of control are used to externally specify configuration of and dynamically load code often from different .jar files, which seems like what you’re trying to do.

    Of course, you can always load code by class name with something like this:

    public interface IPlugin {
        // some methods that all the plugins will have in common
    }
    
    private static IPlugin loadIPluginByClassName(String plugInClassName, ClassLoader classLoader) {
        // NOTE: throws NoClassDefFoundError or ClassNotFoundException if cannot load the class
        // or throws ClassCastException if the loaded class does not implement the interface    
        Class<?> cls = classLoader.loadClass(plugInClassName);
        IPlugin ans = (IPlugin) cls.newInstance()
        return ans;
    }
    

    You’ll need to call loadIPluginByClassName() with a package qualified class name and class loader, as in

    IPlugin pi = loadIPluginByClassName("com.test.something.MyPlugin", SomeClassInYourProject.class.getClassLoader());
    

    The plugin can be in its own .jar as long as that .jar is on the classpath.

    If you don’t want to load them from an external .jar, you can use the simpler

    IPlugin pi = loadIPluginByClassName(MyPlugin.class.getName(), SomeClassInYourProject.class.getClassLoader());
    

    this creates a direct reference to your plugin class (which can be helpful in that such can be found as a reference)

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

Sidebar

Related Questions

I'm working on a small Java project that now connects to a MS SQL
I have a working project that Im amending, it crashes after trying to use
I'm working in a project that need to get SVD (Single Values Decomposition) for
We have in one of our applications a single eclipse project that contains all
I'm working on a project that connects to Oracle. It Brings back data through
I'm working on a project that involved getting information from two different servers. What
I am working on a project that has to have authentication (username and password)
i'm working on a project that consists of a website that connects to the
I'm working on a project in Ruby right now that is essentially a web-app.
I'm working on a project in AS3 that connects to a PHP file. I

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.