[java] Java's equivalent of DLLs?

Started by
8 comments, last by redmilamber 18 years, 9 months ago
Self explanatory. Is it possible to write a plugin architecture with Java? I know Eclipse did it; hopefully it's not too complicated to do. Thanks!
I eat heart attacks
Advertisement
Class files. Class loader, reflection, interfaces, abstract classes [google]

In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.

Thanks
I eat heart attacks
You can work with DLLs in java - use the System class or the Runtime class to load them. Take a look at the documentation for more details.

As far as plugins are concerned, you can build entire frameworks and package them in a single .jar file, to be used as a library or as an extension for your applications. This approach is often used to provide a certain level of interaction between two or more application with different taks.

No need to mention that you will have to prepare the targetting application's architecture to be able to use such extension - and that's where you get a hold on Washu's suggestion and google for standard implementation.
a.k.a javabeats at yahoo.ca
Dynamic Class Loading
The CompilingClassLoader (pdf)

The pdf document is a complete guide on how to write your own classloader, with the option to be able to load uncompiled .java files. Can be useful for scripting and runtime editing.
You sir, are genius.
I eat heart attacks
Although often a full classloader isn't needed. I've often done a really simple version simply by defining a base class and/or interface, then listing the plug-in's class name in an external data file. Chuck in a bit of Class.forName(String) and Class.newInstance() and you're done. :)
Quote:Original post by Rickmeister
The pdf document is a complete guide on how to write your own classloader, with the option to be able to load uncompiled .java files. Can be useful for scripting and runtime editing.

Or you could use Beanshell, which does exactly that (and more) and is already written and debugged. [razz]
You too, sir, are brilliant. Too bad I can't rate you any higher because I've already rated you =D.
I eat heart attacks
It's offline right now >:( (whilst mangling the HTTP parser to try and help Sun fix what *appears to be* an ultra-serious bug in NIO) but http://javagamesfactory.org has free source code for a rather excellent automatic class locater and loader, which you may well find rather helpful.

Can't copy/paste the URL cos the server's offline :(.

It doesn't have a dynamic classloader built-in, IIRC, but the source is there, with syntax highlighting, so you're free to alter it yourself.

This topic is closed to new replies.

Advertisement