Just what is Java EE really?

JavaJakarta Ee

Java Problem Overview


Java EE has this "mysterious shroud" around it for younger Java developers - one that I've been trying to lift myself for quite a while with little success.

Confusion arises from:

  • Java EE seems to be both a library and a platform - there are multiple ways to "get" the Java EE library, typically from something like Oracle's Java EE SDK download. However, the Java EE library will not work, nor compile unless if your code is being run on or has access to a Java EE application server (such as JBoss, GlassFish, Tomcat, etc). Why? Can't the libraries function outside of the application server environment? Why do I need something massive as JBoss just to compile simple code to send an email?

  • Why are Java EE libraries not "standard" and included in the regular JVM download and/or the SDK?

  • Why are there so many Java EE offerings when there is really only two main flavors of standard Java (Oracle JVM/SDK | OpenJDK JVM/JDK)?

  • What can one do with Java EE that they cannot do with standard Java?

  • What can one do with standard Java that they cannot do with Java EE?

  • When does a developer decide they "need" Java EE?

  • When does a developer decide they do not need Java EE?

  • Why is Java EE library version not in sync with standard Java library releases (Java EE 6 vs. Java 7)?

Thanks for helping me clear the flog!

Java Solutions


Solution 1 - Java

Why can't the libraries function outside of the application server environment?

Actually they can. Most of the libraries can be directly used standalone (in Java SE) or included in a .war (practically that's nearly always Tomcat). Some parts of Java EE, like JPA, have explicit sections in their respective specifications that tells how they should work and be used in Java SE.

If anything, it's not so much an application server environment per se that's at stake here, but the presence of all other libraries and the integration code that unites them.

Because of that, annotations will be scanned only once for all your classes instead of every library (EJB, JPA, etc) doing this scanning over and over itself. Also because of that, CDI annotations can be applied to EJB beans and JPA entity managers can be injected into them.

Why do I need something massive as JBoss just to compile simple code to send an email?

There are a few things wrong with this question:

  1. For compiling you only need the API jar, which is below 1MB for the Web Profile, and a little over 1MB for the full profile.
  2. For running you obviously need an implementation, but "massive" is overstating things. The OpenJDK for example is around 75MB and TomEE (a Web Profile implementation containing mail support) is only 25MB. Even GlassFish (a Full Profile implementation) is only 53MB.
  3. Mail works perfectly fine from Java SE (and thus Tomcat) as well using the standalone mail.jar and activation.jar.

Why are Java EE libraries not "standard" and included in the regular JVM download and/or the SDK?

Java EE in a way was one of the first attempts to split up the already massive JDK into chunks that are easier to manage and download. People are already complaining that the graphical classes (AWT, Swing) and Applets are inside the JRE when all they do is run some commands on a headless server. And then you also want to include all the Java EE libraries in the standard JDK?

With the eventual release of modularity support we'll just have a small base JRE with many things separately installable as packages. Perhaps one day many or even all classes that now make up Java EE will be such package as well. Time will tell.

Why are there so many Java EE offerings when there is really only two main flavors of standard Java (Oracle JVM/SDK | OpenJDK JVM/JDK)?

There are more than just two flavors of Java SE. There is at least the IBM JDK, the previous BEA one (JRocket, which is being merged into the Oracle/Sun one because of the acquisition), various other open source implementations and a slew of implementations for embedded use.

The reason behind Java SE and EE being a specification is that many vendors and organizations can implement it and thus it encourages competition and mitigates the risk of vendor lock-in.

It's really no different with C and C++ compilers, where you have many competing offerings as well all adhering to the C++ standard.

Why is Java EE library version not in sync with standard Java library releases (Java EE 6 vs. Java 7)

Java EE builds on Java SE, so it trails behind. The versions do correspond though. Java EE 5 requires Java SE 5. Java EE 6 requires Java SE 6 and so on. It's just that mostly when Java SE X is current, Java EE X-1 is current.

Solution 2 - Java

Here are a few quickly composed answers to your questions...

  • Why can't JavaEE libraries function without an application server? The services provided by JavaEE (container managed transactions, container managed dependency injection, timer service, etc..) inherently involve JavaEE compliant Application Servers (for example: GlassFish, JBoss, WebSphere, etc...). Therefore the JavaEE libraries serve no purpose without such a container. "Why do I need something as massive as JBoss just to compile simple code to send an email?" You don't. There are ways to send an email without JavaEE... But if you want to do it the JavaEE way, you need a JavaEE container.

  • Why are JavaEE libraries not included with JavaSE download? The same reason that many libraries aren't included: it would be overkill. Since you can't even use the JavaEE libraries without an application server, why bother to include them? JavaEE should be downloaded if and when a developer installs an application server and decides to use JavaEE.

  • Why are there so many JavaEE offerings? Are there really "so many" JavaEE offerings? If so, please list some of them. More accurately I believe there are multiple implementations of the same APIs.

  • What can one do with JavaEE that they can't do without standard Java? Lots. You can't rely on an application server to manage transactions or persistence contexts without JavaEE. You can't allow an application server to manage EJB dependency injection without JavaEE. You can't use an application managed timer service without JavaEE. The answer to this question should make the answer to the first question quite clear... Most of the services provided by JavaEE require a JavaEE container.

  • What can you do with JavaSE that you can't do with JavaEE? Um... I don't know.

  • When does a developer decide they need JavaEE? This question is completely subjective... But if you need any of the services provided by JavaEE, you start to think about it. If you don't know what JavaEE is... you probably don't need it.

  • When does a developer decide they do not need JavaEE? See previous answer.

  • Why is JavaEE library version not in sync with JavaSE version? Good question. I won't pretend to know how to answer it... But I would guess the answer is: "because they're not in sync".

Solution 3 - Java

At bird's eye view, Java EE is a platform, i.e. something that we can build on.

Taking a more technical perspective, the Java Enterprise Edition standard defines a set of APIs commonly used for building enterprise applications. These APIs are implemented by application servers - and yes, different application servers are at liberty to use different implementations of the Java EE APIs.

> However, the java ee library will not work, nor compile unless if your code is being run on or has access to a Java EE application server (such as JBoss, GlassFish, Tomcat, etc).

You compile against the Java EE APIs, so you only need those APIs at compile time. At runtime, you'll also need an implementation of these APIs, i.e. an application server.

> Why do I need something massive as JBoss just to compile simple code to send an email?

You don't. However, if you wish to use the Java EE API for sending mail, you will need an implementation of that API at runtime. This can be provided by an application server, or by provided by a stand alone library you add to your classpath.

> Why are Java EE libraries not "standard" and included in the regular JVM download and/or the SDK?

Because only the APIs are standardized, not the implementations.

> Why are there so many Java EE offerings

Because people disagree on the right way to implement certain features. Because different vendors compete for market share.

> What can one do with Java EE that they cannot do with standard Java?

Since Java EE implementations are built with "standard Java": Nothing. However, leveraging the existing libraries can save a great deal of effort if you are solving typical enterprise problems, and using a standardized API can prevent vendor lock-in.

> What can one do with standard Java that they cannot do with Java EE?

Nothing, since Java EE includes Java SE.

> When does a developer decide they "need" Java EE? When does a developer decide they do not need Java EE?

Generally speaking, the Java EE APIs solve typical, recurring problems in enterprise computing. If you have such problems, it usually makes sense to use the standard solutions - but if you have different problems, different solutions may be called for. For instance, if you need to talk to a relational database, you should consider using JPA. But if you don't need a relational database, JPA won't help you.

Solution 4 - Java

What is Java EE?

Let's start from canonicity definition at wiki:

> Java Platform, Enterprise Edition or Java EE is Oracle's enterprise > Java computing platform. The platform provides an API and runtime > environment for developing and running enterprise software, including > network and web services, and other large-scale, multi-tiered, > scalable, reliable, and secure network applications.

The main point here is that Java EE is a platform provides an API, not some concrete library.

What for Java EE needed?

The main scope of Java EE is the network based applications, unlike Java SE oriented to the desktop applications development with simple network support. This is the main diference between them. Scalability, messaging, transactioning, DB support for every application... the need in all of this has increased with the evolution of the network. Of course a lot of ready solutions which Java SE provides are useful for network development, so Java EE extends Java SE.

Why do we need application servers to run our code?

Why do we need operation systems? Because there are a lot of painful work with hardware we need to do to make even simpliest application. And without OS you need to do it again and again. Oversimplified OS is just a programmatic container, which provides us a global context to run our applications.

And this is what the application servers are. They are allows us to run our applications in their context and provides us a lot of highlevel functionality which is needed for enterprise highloaded network applications. And we are don't want to write our own bicycles to solve this problems, we are want to write code which will satisfy our business needs.

Another example here could be JVM for Java.

Why Java EE doesn't contains onboard app server?

Hard to say for me. I think, it was done for more flexibility. Java EE says what they should do, they decide how to do it.

Why JVM doesn't include Java EE?

Because they directed to different market sectors. Java EE has a bunch of functionality which is doesn't need for usual desktops.

Why are there so many Java EE offerings?

Because Java EE only describes the behaviour. Everybody can implement it.

What can one do with Java EE that they cannot do with Java SE?

To conquer the internet. It's really hard to do with Java SE applets and sockets :)

What can one do with Java SE that they cannot do with Java EE?

As mentioned above Java EE extends Java SE, so with Java EE you should be able to do everything what is available for Java SE.

When does a developer decide they "need" Java EE?

When they need the power of Java EE. All what is mentioned above.

When does a developer decide they do not need Java EE?

When they write a usual console or desktop application.

Why versions of Java SE and Java EE are unsynced?

Java always had troubles with it's technologies naming and versioning. So this situation is not an exception.

Solution 5 - Java

Java EE is all about container concept.
Container is an execution context within which will run your application and which provide this last a set of services. Each kind of service is defined by a specification named JSR. For example JSR 907, JTA (java transaction Api) which provide a standard way to manage distributed transaction against different resources.
There are generally many different implementations for a given JSR, the implementation you will use depends on the container provider, but you don't really mind about that as you are sure the behavior respect the predefined contract : the JSR API.
So to take advantage of Java EE, you need to run your application inside a container. The two main ones are EJB and servlet container which are both present on any Java EE certified application server.

The aim of all of this is to defined a standard execution environment to allow to package your application with only the essentials, id.est. your business. It avoids to depend on a unknown and various set of third-party libraries that you would have to package and provide with your app otherwise, and which may be sources of conflict with other apps on the server. In Java EE you know that all standard non functional requirements like security, transaction, scalability, remote invocation, and many more will be provided by the container (factorized for all apps running inside it) and you just have to base your work on its.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSnakeDocView Question on Stackoverflow
Solution 1 - JavaArjan TijmsView Answer on Stackoverflow
Solution 2 - JavajahroyView Answer on Stackoverflow
Solution 3 - JavameritonView Answer on Stackoverflow
Solution 4 - JavaMaxim KolesnikovView Answer on Stackoverflow
Solution 5 - JavaGabView Answer on Stackoverflow