Java – Best Java web application framework for a PHP developer


I had been life long PHP developer. But am now forced to write in Java (or at least on JVM) the final version of a prototyped PHP web application.

Would like to add that I am not quite unfamiliar with Java. Wrote applets in the old days. Besides, am familiar with most other scripting languages, plus RoR.

But web app in Java is making me confused with so many options. Therefore my question: which framework would you recommend for a PHP developer? Would prefer less typing, and less XML. Is there a RoR like framework in Java or in any of the JVM languages?

Best Solution

There is a RoR like framework for the Java Virtual Machine (actually a port of RoR) called Grails. It does not use Java but a Ruby-like language called Groovy. You are however free to mix Groovy and Java classes in your Grails projects.

There is also a port of Ruby called JRuby that runs on top of Java on the Java Virtual Machine --and yes, you can run RoR with it (see here).

Apart from RoR-like environments, the easiest framework to use with the less XML is the simpler Servlet framework. You only need to set up a web.xml and the rest is pure Java and JSP (a PHP like templating/logic dialect based on Java).

There is also Quercus a PHP implementation on top of Java. This will allow you to port your PHP code and even mix it with Java classes.

In order of prevalence and support, the option with the most commercial support, available documentation, books and jobs is the plain Servlet framework one --and then Grails, which is owned and supported by SpringSource, a major player on Java frameworks.

After you are familiar with the Java language and concepts, you could move to a higher-level web framework like Spring MVC or Struts 2, where, using Annotations (a kind of metadata added on code) you can do with very little XML or even no XML at all. See this for an example.

Related Question