views:

457

answers:

7

I am little confused about Java frameworks (I am coming from .NET). Do you need different server setups to run Java, J2EE and JSP? Does Java make a distinction in frameworks for enterprise and non-enterprise deployments? Beans? Struts?

Can someone make sense of this for me?

.NET has:

  1. Windows development (Winforms, WPF)
  2. web: i) webforms, ii) mvc
A: 

There is one JDK (only JDK 6 is supported today) and the Java Runtime Environment (JRE 6).

Typically you need only the JRE, but some frameworks need the tools.jar (i.e. javac) to run.

Even server and client modes can be detected and the JEE libs come with the application server (or web server) you use.

Thomas Jung
Even Java 1.4 is supported if you either use Solaris or pay Sun money.http://java.sun.com/javase/support/javaforbusiness/
Thorbjørn Ravn Andersen
A: 

If you are going to implement a web application with Java, you can use Apache or Tomcat as a webserver.

To develop in Java, I suggest downloading NetBeans from here:

http://netbeans.org/downloads/

I prefer NetBeans than Eclipse because it is more similar to .NET's IDE, which basically means, it is more helpful.

With NetBeans, you can program every type of Java application, from a client java application, to a servlet, applet, etc...

Chris
+1  A: 

There are several versions of the JDK (1.4, 5, 6), much like there are several versions of .NET (1.1, 2.0, 3.0, 3.5). J2SE and J2EE are really just different packagings of the same version. J2EE includes some extra namespaces that aren't in J2SE.

From wikipedia:

Java Platform, Enterprise Edition or Java EE is a widely used platform for server programming in the Java programming language. The Java platform (Enterprise Edition) differs from the Java Standard Edition Platform (Java SE) in that it adds libraries which provide functionality to deploy fault-tolerant, distributed, multi-tier Java software, based largely on modular components running on an application server.

tvanfosson
+3  A: 

There's a few different ways of looking at this.

Firstly, the only current version of Java is Java 6 currently at Update 17 or so. Java 5 and earlier have all been end-of-lifed. What's a little confusing is that starting at version 1.2 Java adopted the name "Java 2" (and was referred to as J2SE or "Java 2 Standard Edition") so it was Java 2 version 1.2. After Java 2 version 1.4 (or more simply Java 1.4). Version 1.5 became Java 5 or J5SE although J2SE is still pretty common.

The other version of Java that's relevant is Java Enterprise Edition ("JEE"), formerly J2EE ("Java 2 Enterprise Edition") with version 6 being imminent. JEE specifies a set of standards for server apps. The most important part is the servlets specification, which is the basis for 99.9% of Java Web frameworks. It has versions and is currently at either version 2.5 or 2.6 (I forget). Apache Tomcat is the reference implementation of the servlets specification.

Another part is EJB ("Enterprise Java Beans") currently at EJB3/3.1. It's a component architecture and really heavyweight. It's not used anywhere near as often as the base servlets specification.

Whereas Tomcat is a Web container, full JEE supports is provided by what's called an application server. Examples include Glassfish, JBoss, Weblogic and Websphere.

Java classes are often packaged as JARs ("Java ARchives"), which is simply a zipped file with a specified directory structure.

Web applications are packaged as wars ("Web ARchive"), which is just a jar with a different extension. WARs may contain libraries in JAR form.

Full JEE apps are packaged into EARs ("Enterprise ARchives"), which again is just a different file extension and it may contain war and other files.

Now to complicate this there are about a bazillion Java Web frameworks such as Struts, Spring MVC, Tapestry, Wicket and many, many others.

Also, it's fairly common for Java Web and enterprise apps to use the Spring framework. Spring is (imho) a must-have for Java serverside development as it simplifies a lot of vendor and library differences and makes your application far more pluggable.

Confused yet?

cletus
JEE, yes! Things become complicated with multiple vendors.
Thomas Jung
JARs are zipped files with a specific directory structure and some optional meta information.
Thorbjørn Ravn Andersen
"Firstly, the only current version of Java is Java currently at Update 17" <-- I added a 6 to this to make it correct.
R. Bemrose
A: 

There are 3 main Java platforms:

  • Java SE (standard edition)
  • Java ME (mobile edition)
  • Java EE (enterprise edition)

They all have the Java programming language in common, but differ in terms of APIs and libraries included in them.

From your question I'm guessing you're looking at Java EE?

Although it is possible to code an enterprise application in Java SE, Java EE is the natural choice because it takes care of many things you would face and allows you to focus on the interesting and useful parts of your application.

Java doesn't really distinguish from enterprise and nono-enterprise, in fact, you can use the APIs from Java SE in Java EE, and it's possible to use Java EE APIs in Java SE programs.

So what's the difference then?

Essentially, they are all platforms, execution environments. Java EE is more suited to developing big projects than Java SE, and as such includes various servers and things to help you code those big applications.

Beans, Servlets, Apache Tomcat server, Glassfish server all fall under the Java EE platform.

chrisbunney
+7  A: 

These are the most commonly used terms that correspond to your "Java versions":

  • JRE: Java runtime environment, what's needed to run Java programs
  • JDK: Java development kit, a JRE plus compiler and some additional tools
  • Jave SE: Standard Edition, the API library that comes with every JRE and JDK for desktop use
  • Jave EE: Enterprise Edition, additional APIs that extend the J2SE for business use, meaning mainly server applications - this includes JSPs
  • Jave ME: Mobile Edition, a set of APIs (mainly a subset of J2SE) for mobile devices like phones

(The latter three are often also written as J2SE, J2EE and J2ME meaning "Java 2 ___ Edition" - Sun's naming and versioning convention are rather confusing)

Note that all of these are basically specifications, and there are implementations from different vendors. For example, you can get a J2SE 6 JDK not only from Sun, but also from IBM and Oracle.

Michael Borgwardt
Android could count as a "Java" version on its own. Or even GWT.
Thomas Jung
Also they prefer not to be called J2?? these days
Mobs
Right, though Sun's not even being entirely consistent on their main download page: http://developers.sun.com/downloads/
Michael Borgwardt
Can Also add JavaFx, Sun's response to silverlight and flash/flex.
Knife-Action-Jesus
JavaFX has its own language, so though it is a platform and runs on the JVM, it's not Java.
Michael Borgwardt
A: 

First you have the Java SE which contains the standard Java API. You can download it as JRE (only runtime) or as JDK (includes developer tools like java compiler).

Then you have the Java EE which contains the enterprise Java API. Java EE is in fact an abstract API (exist of almost only interfaces, abstract classes and API contracts). You need a concrete implementation to get a running Java EE platform. In case of JSP/Servlet you basically need a servlet container. Commonly used ones are Apache Tomcat and Sun Glassfish (which is bundled in Sun Java EE download).

You do NOT need to download the Java EE from Sun when you need Apache Tomcat. Just the Java SE is enough. The Sun Java EE download contains basically the Glassfish server and is also available as a bundle with Netbeans IDE (which I personally don't recommend for web development; Eclipse or IntelliJ are better choices for web development).

Let assume you would like to use Eclipse and Tomcat, then to get started with web development you basically need the following:

  1. Java SE JDK 1.6
  2. Apache Tomcat 6.0 (core, binary distributon)
  3. Eclipse IDE for Java EE developers
  4. jstl-1.2.jar (standard JSP taglib, use it instead of scriptlets!)

To kickoff with all:

  1. Install Java SE.
  2. Extract Tomcat zip and put it in desired location.
  3. Extract Eclipse zip and run eclipse.exe.
  4. In Eclipse's Servers view, add new Tomcat server and point to the Tomcat location.
  5. In project explorer, create new Dynamic Web Project and pick the Tomcat from the list.
  6. In the created project, drop the JSTL JAR in /WEB-INF/lib.

That should be it. You can create JSPs in /WebContent folder and create classes (servlet, filter, bean, domain, utility, etc) in src folder.

As to Struts, it has nothing to do with Sun. It's a component based MVC framework of Apache which is roughly said the competitor of Sun JSF. You can download it separately, put the libraries in WEB-INF/lib and use it in the project.

BalusC
Note that Apache Tomcat is just a servlet container. If you want a full implementation, see Apache Geronimo instead.
R. Bemrose