Example of MVC in java/jdk

Go To StackoverFlow.com


Can someone give me an example of application/framework/tool in java/jdk library that is based on MVC design pattern? I was asked this question at an interview recently. I replied that most of the java swing components are designed based on MVC. But the interviewer said he is looking for something more complex than that. Thanks.

2012-04-03 19:38
by Martin Prakash
what do you mean by "java/jdk" ?? JavaSE (desktop-based) or JavaEE (server/web-based) ?? those environments are not the sam - Alonso Dominguez 2012-04-03 19:44
If the interviewer thinks that Swing is not complex, you probably don't want to work on whatever he does consider complex.. - Michael Borgwardt 2012-04-03 19:45
I think he was referring to JavaSE. I told him about individual components in swing so he asked for something more complex. So I don't think he implied swing is not complex and I don't think swing framework was the answer he was looking for - Martin Prakash 2012-04-03 23:10
Thanks for the answers guys. From the look of it either I misunderstood his question or there is no simple straight forward answer - Martin Prakash 2012-04-05 17:56


The Java base Java EE stack can be considered MVC, if you use objects as the models, jsps as the views, and servlets as the controllers.

Spring MVC would be another example of a popular library that is based off MVC.

2012-04-03 19:42
by hvgotcodes
Yes, I'm aware of that. But I think he was asking for something within JavaSE/JDK. Thanks - Martin Prakash 2012-04-03 23:14
@martin updated my answer with another exampl - hvgotcodes 2012-04-03 23:38


Apache Struts is an example of such framework.

2012-04-03 19:44
by tenorsax


Apache OFBiz, but i don't recommend it's usage for bussiness.

2012-04-03 19:51
by Ulises Layera


Struts is probably the largest most popular pure MVC framework in use, though it is feeling its age and SPRING which is more AOP, is out there as well.

2012-04-03 20:02
by Speckpgh


When talking about JavaSE, an MVC framework is Swing (or at least something close to it), as you pointed out. I don't really understand what he meant for "something more complex" but there are other options like EclipseRCP.

Eclipse is well known as an IDE, but basically, it is a desktop application built upon a framework that every user can use to build his/her custom desktop application, since it's open source. It is "more complex" than Swing (even though Swing is complex enough) because they are compound of multiple layers out of the box. From the OSGI implementation (which is the most basic piece of software) to the top layer in which you can find structures as views, editors, perspectives, commands, add-ons, etc.

In general terms we can say that in EclipseRCP intermediate layers, the V is the Eclipse SWT library (the components), the C is the Eclipse JFace library and the M is the model of your own application. At the top layer, all of the "complex" structures I mentioned in my previous paragraph (perspectives, views, editors, etc.) are also part of the C as well, but in a higher level.

It's the closest thing I can think of regarding an MVC framework for JavaSE (excluding Swing). The last version of it (Eclipse E4) has made a good cleanup of the complexity so I don't know if that is "complex enough" to answer the question. If you want to know more information read this tutorial about Eclipse E4.

And, by the way, with the Netbeans platform you could also implement a desktop-based application following an MVC approach (or at least something similar) and it's based in Swing.

2012-04-04 18:05
by Alonso Dominguez


I am also struggled with mvc in past and i learnt alot now,see this tutorial mvc simple program(adding two numbers)

2012-08-18 12:43
by padman