views:

141

answers:

3

I am new to Java (but have a fair bit of .NET experience).

I need to get a Java application up and running quickly, so what I am looking for here is advice on components that will simplify or reduce the pain of common tasks and whose payoff will either be immediate or at least come with minimal investment in time spent learning how to use the component. I don't have weeks to spend getting to grips with complex or extensive frameworks - I am looking for add-ins that are easy to use and remove some of the propblems of using raw APIs. However, if the raw API is the best option for any of these tasks, that's fine, let me know ...

Data Layer I want to write specific providers for MySQL, MSSQL, Postgres but otherwise data access is pretty simple stuff. I will probably need transactions. What do you suggest? Does say, Spring Data Access, offer anything worth having over JDBC? Anything else I need to think about? My guess is something like Hibernate is going to be overkill and take too long to get up and running with - what do you think?

Middle Tier Loosely coupled, interface based business layer. I need to be able to interact with the middle tier through a web app and a desktop app - what is the best way to expose this? Web service?

Desktop App I know about Swing - are there any other simple desktop UI components? I will need some kind of scheduling component to run background tasks.

Web App I will need some kind of cache, I need user sessions, I need dynamic pages. From what I can tell JSPs are a Java equivalent of PHP or some other server side scripting language (and don't support state). An MVC framework may be overkill unless there is a framework that is very straight forward to get working with?. I heard there is a Java equivalent of ASP.NET web forms - is it any good? Maybe JSPs will suffice here?

I'm looking for practical advice / your experiences of components, rather than a list of web links :)

Thanks for any advice ..

+2  A: 

I would check out Grails for the model/controller/view mechanism and web front end. It will get you up and running very quickly with an ORM, a model, dynamic pages etc. (it's a RoR - Ruby-on-Rails - model).

From there, I would look at using Java RMI to communicate with a desktop front end. RMI comes as standard with Java and is a natural fit for a Java-to-Java communication requirement. I wouldn't look at web services unless you have a multi-language/platform requirement. RMI is pretty simple to set up, with little configuration.

Your RMI-enabled service layer will have to intercept with the Grails-provided model, but that should be trivial. To reduce possible client/server incomaptibilities (caused by interface changes), you can serve up the Java desktop via (say) Java Web Start (you'll have a web server courtersy of Grails) and it can come from the same codebase that your server is running. Up-to-date deployments are maintained as you update the back end.

Brian Agnew
Thanks Brian, some nice suggestions, just what I was looking for. What other alternatives are there to Grails for the web front-end?
MalcomTucker
Well, other answers here suggest solutions for the view/controller mechanism (e.g. Struts). However I suggested Grails since it does the complete MVC via an ORM in a simple and integrated fashion. If you choose something else, then you'll have to mix and match various different tools (which will work, and I'm not averse to this, but it's more effort)
Brian Agnew
+2  A: 

AppFuse is a tool that can kick-start and preconfigure a variety of java projects, using best-practices. The generated code can also be used to learn-by-example.

AppFuse is an open source project and application that uses open source tools built on the Java platform to help you develop Web applications quickly and efficiently. It was originally developed to eliminate the ramp-up time found when building new web applications for customers. At its core, AppFuse is a project skeleton, similar to the one that's created by your IDE when you click through a wizard to create a new web project.

  • For the Data layer : JPA (Hibernate, or another JPA provider)
  • For the Middle tier : Spring - it is extremely powerful and provides many things like transaction support, schedulling, etc. It can be easily used together with Apache CXF to expose Web-Services.
  • For the Web app - JSF, Spring MVC, Struts
  • For the Desktop app - Swing is perfectly OK. It has the ability to process background tasks. SwingX - a bunch of nice components.

AppFuse supports all of the above.

Bozho
+2  A: 

I'll limit my answers to the webapp part only as things I'd like to answer other parts are already answered by others.

From what I can tell JSPs are a Java equivalent of PHP

Not entirely true. JSP can do more than that. Even more, (ab)using JSPs the PHP way (with inline Java code as scriptlets) is considered bad practice. JSP is supposed to be used as a template in which you can control the page flow dynamically using taglibs such as JSTL and access the backend data using Expression Language.

I heard there is a Java equivalent of ASP.NET web forms

It's called JavaServer Faces (JSF). There's however competition, e.g. Apache Struts and Spring MVC.

- is it any good? Maybe JSPs will suffice here?

JSF (as any other decent MVC framework) abstracts all the stuff you need to take account with in a normal MVC application away so that you end up with just a XHTML (or JSP) file and a Javabean class. This way you don't need to control requests (custom Servlets, etc), process request parameters (request.getParameter() and so on), the basic validation/conversion (requireness, string/number/date input type conversions), update model values (set processed/converted/validated parameters in javabeans), etc. The MVC framework will take care about all that boring work transparently.

JSPs may suffice if you need to develop per saldo just a few pages. But if you want to develop more pages or webapplications, then you'd like to already have a framework so that you don't need to reinvent the usual work again and again.

BalusC