Helping a beginner for java web application - java

I have pretty big background of .net, and I've decided that i want to port one of my websites to Java. (now with the asp.net MVC craze, I've figured I'd better learn a more mature approach to MVC).
i've downloaded eclipse (easyeclipse distro to be exact, and am ready and willing to develop my first website in java).
i've programmed j2me application before, so i know the language and some of the framework.
can someone guide me? any advice?

Although I'm not very aware of "asp.net mvc" is all about, I would suggest you to take a look at Spring it may be interesting.
Probably is too complicated at the beginning but when you get the concept it turns out very easy to follow.
Spring has 5 core modules ( which I don't remember exactly ) but they were like:
AOP
ORM
MVC
Core
( some other I'm missing here )
The MVC part uses a lot of annotations to make life easier. There's a very big community around Spring.
Here's an introductory article about spring.

Java has a ton of frameworks you can choose from. The technology stack that I use for my Java development is either:
Spring for IoC.
Hibernate for the data layer.
Struts2 for the MVC framework.
I have also swapped out spring and used Guice for the IoC.
Spring also has MVC, but I tend to like Struts2 better.

I'd recommend looking at Grails, it lets you become comfortable with all the java libraries and frameworks like Spring, SpringMVC, Hibernate, SiteMesh, and so on but gives you a much better DSL for web applications and much more concise code with the Groovy language (think of it as Java with dynamic typing, blocks, closures, and so on).
If you'd rather stick to pure Java I'd recommend looking at the Stripes framework and the following book:
http://pragprog.com/titles/fdstr/stripes

If you interested in web applications specifically, I would recommend using MyEclipse http://www.myeclipseide.com. Basically, this is a version of eclipse with all the web server integration and functionality built in. I've been using it for a few years and it's much easier to develop with than with plain vanilla eclipse. Depending on how much your going to use it, you have to decide whether the $55 annual subscription is worth it for you.

I'm a little confused. does spring framework actually a full blown framework? doesn't Java already have a framework? (by framework i mean all those misc libraries).

Related

Java webdevelopment IDE/Server/Documentation

I have been using PHP (OOP) with various Frameworks for all my webdevelopment projects for the last few years. Next year I'll have to learn Java as part of CS university course, so I thought it may be a good idea to switch to Java for some of my smaller webdevelopment projects, so that I can get to know Java in advance.
What do I need to use Java for backend web development? What IDE/Server software/etc. should I use? What frameworks are available and which documentations could one recommend?
I know this is strictly not a Stackoverflow question, but I'd really like to hear the opinion of the very professional community here at Stackoverflow!
The web development component of Java is called Java EE. You should look into that.
As IDE you can use Eclipse, Netbeans, etc. (you can download versions that are specifically aimed at Java EE development, with bundled servers like GlassFish or Tomcat).
Use all of these technologies and learn what the terms mean: Servlet, JSP, JSTL, Filter, Tag library (create your own).
A very popular framework is Spring. Spring Core and Spring MVC has recreated most of the Java EE components but in a way that is easier to use.
The DWR library makes AJAX very easy.
Learn how to use Spring ORM, Hibernate or JPA.
I also just want to add my own answere to show what I choose in the end to work with:
IDE: NetBeans
Framework Play! Framework

How to develop Java webapps in a Ruby on Rails-like way?

We've got an app that needs to run in a Java app server. I've got to develop a webapp to go with it. I've started reading about Ruby on Rails, and I really like the approach: MVC, convention over configuration, tons of stuff taken care of for you.
I may be dreaming the impossible dream, but are there any Java webapp development frameworks out there that work in a similar way?
Straight JSP is miserable, because logic and presentation are mixed. Simple template systems, like Velocity and Freemarker don't do the database stuff. I don't know much about Spring.
Everybody here knows Java, and we don't have time before the next release cycle to learn an entirely new language and library, else I'd plunge into RoR in a serious way.
Not impossible at all. It's already been done.
Here are a few Java-equivalents:
Grails http://www.grails.org/
SpringRoo. http://www.springsource.org/roo
Spring MVC. http://www.springsource.org/
All are products of SpringSource. If you're getting serious about Java web development, I highly recommend you check them out.
Grails was actually inspired by Rails, hence the name, so you'll see many similarities in features and paradigms between the two, including MVC, convention-over-configuration, and code generation. So if you're looking to get right into Rails-like development in Java, I highly recommend Grails. I should note that Grails has more features than Rails, some of which I think Rails should adopt. An example is Grails provides a service layer to handle all business logic. You could easily implement a service layer in Rails, but its convenience we all love, and because Grails includes it, it is more convenient. I've hopped between Rails and Grails once upon a time, both great frameworks.
Keep in mind that you can do Rails development with Java as well, via JRuby, which is not a bad option either. You get all the features of the Ruby language (v. 1.8), along with the ability to integrate and use Java libraries within your Ruby code.
SpringRoo is SpringSource's new code generator framework, so you can use it with the Spring framework to aid in agile/rapid application development.
Grails is actually built on-top of the Spring framework and Groovy. Groovy is Java-derivative which looks more like a scripting language and provides all the meta/dynamic programming goodness that you see in languages such as Ruby and Python. However, Groovy allows you to write Java code as well, so there's no need to learn it, not entirely at least.
Have a good look at the the Play Framework. I think that it's the best way to develop Java web applications at the moment. Certainly the quickest. There is no deploy cycle. Save the code and refresh the browser.
It comes with Hibernate and a host of enhanced functionality that streamlines the development process. Totally REST based and stateless.
Add in jQuery and it feels like web heaven.

Start with Java (JVM) ecosystem

I have came from another question to this one:
How can one start with Java (JVM) ecosystem? What are beginner, intermediate and advanced knowledge-bases (bags!)? To be honest Java ecosystem was always a bit confusing to me, so it would be very helpful to provide some "reference references" and "defacto tutorials" for learning (curve!) JVM.
Note: I want to use JVM with Scala (or Clojure) but not Java itself.
I am a C# developer (WPF, Windows Forms, ASP.NET, Web Services, ... like that).
The Java Tutorial is a good place to start.
Update: you have enough questions for about a dozen posts here ;-) Honestly, you should do some research yourself (Google is your friend), then ask more specific, targeted questions; that would yield better results. (e.g. I don't think anyone can answer your question regarding Swing or JavaFX without more specific details about what you are trying to achieve.) I try to give a few pointers below, about areas I know to some extent.
for servlets and other web frameworks, here is a bunch of tutorials.
Tomcat and Jetty are both application servers.
there are a lot of different web frameworks, because different people have differing preferences, ideas and style, so many have created their own framework. It can be confusing, but at least there is choice :-)
for persistence, apart from JDBC, ORM frameworks are another strong option. I use Hibernate and I can recommend it; in a bigger project it can make your life much easier. Ultimately it depends on your specific project and constraints; there is no single right choice.
AFAIK Java has no equivalent of LINQ.
See also this post for further recommendations.
Java based web applications need to run inside of a web container such as Jetty or Tomcat.
You build your app and deploy it to the container which hosts the application at runtime.
Pure/plain JDBC should only be used directly by simple applications or integration layers that do not have access to the class model.
Most applications that I have seen have used some kind of Object Relational Mapping framework which models the entities as classes at a higher level than plain old JDBC.
Popular O/R frameworks include:
hibernate
toplink
datanucleus
cayenne
For web based development, you could start with AppFuse, see the quickstart guide.
AppFuse is a templating system that generates the skeleton of an application for you.
Then look deeper into what has been generated, and see what frameworks they are using.
AppFuse lets you choose between different technology stacks, so you could compare.
I haven't seen AppFuse support for Guice or GWT.
Guice is a Dependency Injection framework, others that could be used instead are Spring or picocontainer.
Another investigative approach that you could try would be starting with AndroMDA, which is a model driven architecture framework - you start with a UML model and then generate or forward engineer a working application.
AndroMDA also lets you control the choice of the underlying framework implementations by configuring different cartridges, once again you should dig deeper to see what they are using in the generated application.
If you are looking for a basic introduction, then the Java Tutorials are nice. To do other things like Java Web Development, then your going to need to consult google for the respective technology since they vary so widely.
One book though that I highly recommend taking a look at is Java Concurrency in Practice
Yeah, it is almost impossible for new guys to get started. This is going to drive away a lot of developers, and Java is in danger of not having constant new bloods. The old farts would love that, it's great for career security, and that's why they are making Java more and more complicated.

Which framework to choose?

I was thinking which framework would be a good choice to go into. I'm focusing on java apps and tested spring, grails and seam so far. I've also looked aboard java and gave ruby on rails a try too.
In future I will be focusing on portlet development which I've gone through already without a complete framework (just hibernate).
Maybe someone could share some experiences? Or point me to a corner which I don't looked in so far?
Regards and thanks for reading ;)
If you're doing this out of curiosity and to learn something new, rather than to meet specific requirements for a specific project, maybe you'll enjoy the Play! Framework. It contains a lot of stuff from other frameworks and is designed to get you up and going very quickly, with short development cycles and not a lot of arcanae.
Their stated purpose is to be "by Web developers for Web developers". They intend to put the fun back into Web programming.
This sounds good and I've read a few nice things about it in fora and blogs, but I haven't tried it myself yet so that's all the recommendation I can give.
Grails has a plugin for developing portlets, described here.
If you consider Groovy or Grail, you might consider ZK, too. It is an Ajax framework integrated well with Groovy and Grail.
I'd say you go with a framework that targets the programming language you're most proficient in. If you already are good in Java, and you're a quick learner ( to learn Groovy ), Grails could be a good choice.
If you'd like to go with another scripting language, say Ruby/Python, then choose Rails or Django, or Pylons ( the list could go on here ).
If you're going for a Java only framework, I'd go with Spring MVC.
You should have a look at the play framework (SO question).
Finally a Java framework made by Web developers. Discover a clean alternative to bloated enterprise Java stacks. Play focuses on developer productivity and targets RESTful architectures.
I was thinking which framework would be a good choice to go into. I'm focusing on java apps and tested spring, grails and seam so far. I've also looked aboard java and gave ruby on rails a try too.
FYI - Grails is using Spring and Hibernate underneath; SEAM uses JSF and Hibernate.
Grails is the Java equivalent of RoR. It's based on the same idea: "convention over configuration".
It's also important to be clear that Spring is far more than a mere web MVC framework. It's based on DI and AOP and encompasses persistence, remoting, enterprise services, etc. It supports portlet MVC, which is a plus given your requirements.
Personally, I would recommend straight Spring over any of your choices so far if you stick with Java. It's important to know something about what's going on under the covers. If you know Spring well, Grails will be easy.
I'd use Wicket rather than Play! because Play! requires Python as a semi-dependency. With Wicket, you only need Apache and Java and thats it.
I suggest you also check out here:
http://gokhan.ozar.net/best-java-web-frameworks/

Django or RoR like common Java or ASP web-frameworks

I am a fan of big agile software development methodology and love to develop web pages using Django and RoR. However, it creates a big constrain as there are really very few Django or RoR developers to hire.
For a new web project, we will be hiring developers and even though I would love to see these employees using such tools, sadly it will be either impossible to find related developers or even if we find them(virtually impossible for my country), we will be very dependant on them.
Also time is a big constrain thus considering "finding clever programmers and letting them learn these technologies" is not an option.
Under these conditions, I would like to hear common Java or .Net alternatives and why would you suggest them.
I can think of Spring, Hibernate, Stripes, Struts and Wicket for Java
Also Microsoft ASP.NET MVC looks really promising.
EDIT: I Need to mention that I won't be an active developer for this project but act as a manager.
Regards
If you want Java, Spring, and Hibernate with RoR-like "convention over coding", why not try Grails? It's based on Java, Groovy, Spring, and Hibernate. You'll be able to get a lift similar to RoR for web-based CRUD apps.
ASP.NET MVC is quite promising. It "borrows" a lot of its ideas from the Rails framework and community. I am a ASP.NET (MVC)/C# developer primarily, but had the opportunity of doing some Rails development before I moved from traditional ASP.NET WebForms to ASP.NET MVC. After doing development in Rails, I found it quite easy to make the transition to ASP.NET MVC.
Also, I haven't done any web development in Java, but since there are so many web frameworks to choose from, you may not find enough Java developers to build out and ramp up a team quickly enough, all with experience in the same Java web framework.
web4j might be what you're asking for. However, it is not that popular and your developers will have to learn the framework too. I think it will be faster than learning a new language though.
I believe that building a framework in java or .Net that resembles RoR or DJango is very difficult. This because the languages designs are so different. Also because Java and .Net target the enterprise market, which usually requires more robustness.
Agile development really has nothing to do with what languages or tools you're using. Of course, certain tools and methodologies make it easier (MVC tends to make it easier), but my suggestions would be as such:
Go with ASP.NET MVC. It borrows a lot of the good stuff from Rails, and provides some powerful tools that will make developing ASP very friendly to everyone involved.
Use an agile planning tool. I suggest Skinnyboard, as it allows you to do true agile planning.
Don't fret about the tech! Agile is how you manage the project, not the technologies that the project is using.
You're asking how to develop webapps fast with enterprise frameworks vs RoR.
My initial answer is you can't expect to develop webapps in .NET/(Spring/Hiberbnate) as you would for RoR. Lots more setup, lots more to learn and understand at a deeper level. Lots of configuration.
I don't see php here. I assume a lot more people use php. Why not look at php and symfony. Symfony derives its fundamentals from RoR.
If none of the above fit the bill I'd go for Spring/Hibernate/MySQL/Tomcat. We developed multiple largescale web apps with that stack in an agile Scrum/Sprint scenerio
For Java, VRaptor has a controller+view implementation similar to rails actionpack, and uses a DI Container based on Spring. Also has some nice integration with Hibernate/JPA, XML/JSON serialization using XStream, helpers for Integration Tests and a pretty nice documentation.
Haven't tried it myself, but Play! Framework for Java looks very promising. RESTful architecture, MVC and a neat admin interface (like Django) built in.
A platform based on Seam/Hibernate/JBoss sounds exactly like what you're looking for.
Seam is the web framework, Hibernate is the object relational model, and JBoss is the server container.
After coming up with a database schema, you can even use seam-gen to reverse engineer it and do your "scaffolding."
It's flexible, enterprise level, and free to work with.
Furthermore, Java developers are everywhere.

Categories

Resources