3

If I want to make my Java program to be able accept plugins, how can I make Java plugins to use classes of core program without including all the code to the plugin code? How plugin can have access to programs interface without including it to it's own jar file?

asked Mar 3, 2010 at 7:45

2 Answers 2

5

Have a look at the Java Plugin Framework. It uses the concept of extension points or places in your application that are designed to be extended. Plugins are the means that your application is then extended.

answered Mar 3, 2010 at 8:00
Sign up to request clarification or add additional context in comments.

Comments

0

Use java.net.URLClassLoader.newInstance with your application's class loader as the parent.

answered Mar 3, 2010 at 7:56

3 Comments

What if I use reflection to find out if plugin has certain methdo names and class names ? And then call those methods from main program ?
@newbie, that's the general idea, yes. That way, you don't have to know exactly what class(es) you'll be dealing with at compile time. The programmer of a plugin just has to ensure that they conform to the interfaces your application expects.
@newbie @Mike No need for that. You can simply implement an interface/extend a class from the application code.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.