[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.newcomer] Re: Loading jars dynamic from plugins

Walter Harley wrote:

"Franz Philipp Moser" <pm@xxxxxxxxx> wrote in message news:dcb02f1d56d6d9f961e57d6dc824e96b$1@xxxxxxxxxxxxxxxxxx
can I load eclipse with adding some jars to the classpath? This would help a lot!

Do you mean, can you add jars to the classpath that you use to launch Eclipse with, and then expect the classes in those jars to be visible to plug-ins? In general, no, I don't think so; and you shouldn't, anyway.

Eclipse is a modular application platform. (It's also an IDE built on top of that modular application platform.) The thing that makes it modular is that there are strict boundaries placed on how classes in different modules can interact with each other. Those boundaries are defined by the OSGi spec, which Eclipse implements. So the whole point here is that Eclipse is what it is, and is able to do what it does, precisely *because* of these limitations. Making classes visible to all plug-ins is sort of like putting all of your classes in the same package and declaring all your methods and fields to be public: sure, it makes coding easier in the short term, but it makes the code unmanageable as the application grows.

Ok, thats clear and I begin to see eclipse goes an other way than java normaly goes. I always liked the way of adding jars (and therefor classes I need) with the classpath to my app or create a classloader like this.


loader = new URLClassLoader(urls);

urls has the jars found in a specified directory that can be configured by the enduser.

What exactly is it that you are trying to do? Is there some reason that createExecutableExtension() is not a good answer for you?

for example I wan't to "drop in" jdbc drivers, that will be used by the core app loading them the "normal" way with Class.forName("com.mysql.jdbc.Driver"). I don't know witch driver the end user will use so it can be configured and added by installing the right plugin.


I thought this is the right way, but maybe eclipse has an other right way?

Thanks for your help by now, I see things clearer now and try to think the eclipse way ;)