Originally posted by Pradeep Bhat: Library is a set of utility classes which most of the time could be used directly.
Framework is a set of classes which you would extend. Framework provide the implementaion of reprtitive tasks. For example Struts is a MVC framework and your application will extend those classes.
Others opinion may vary.
Pradeep, I guess Sudha is talking about the frameworks like Collections framework... Not kind of Struts Frameworks...
In the case of Collections framework, the framework is very similar to the library... I guess he might want to get a clear explanation on it... In this case, I don't know how to explain it well, we know that we call it Collections framework and don't call it Collections library... I guess it's kinda of naming stuff...
One (not the only) definition of frameworks is that they provide some basic functionality and invite you to plug in your application-specific customizations. You might register a listener for some framework-generated events or extend an abstract framework class and override some "developer hook" methods. Or both.
For example, the SAX parser for XML does all the hard work of parsing tags and attributes and such and invites you to provide a handler for certain interesting bits. That fits the framework definition. For my own use, I made an abstract handler that I extend and override a few methods for specific XML structures. We could call that single handler class a framework, too.
One thing you see in this style is a reversal of control. Without a framework your code has to do everything and controls the sequence and logic directly. In contrast, a framework takes on some of the control and just calls your code at appropriate times.