Java Enterprise Edition
You can use the Java programming language to write anything from simple, stand-alone applications that run on your computer to an entire e-commerce platform.
Multi-tier Architecture

When writing an application, you first have to figure out for which tier you are writing the solution. A typical e-commerce application like Amazon will have components in all the layers of a multi-tier architecture.
The presentation layer is how the user interacts with the application, whether through a desktop, mobile app, or any other device. These days, this layer is mostly written using HTML5, CSS3, and JavaScript as base technologies for desktops, and native frameworks for mobile devices.
The business layer is mostly written in Java in JEE applications. Other competing frameworks for this layer are .NET from Microsoft. PHP and CGI scripts are now considered old-fashioned, and Python is gaining popularity as well.
The database layer mostly uses one of the SQL or NoSQL databases.
A JEE framework lets you easily write solutions for the first two layers: the presentation layer and the business layer.
Since the presentation layer is mostly written in HTML5, CSS3, and JavaScript for desktops (and sometimes mobile devices), and the backend uses Java technologies, a JEE project will have a directory structure created so that both these layers can be developed and bundled together for deployment.
JAVA SE and EE Environments
When you download Java for development, you download the JDK, which stands for Java Development Kit. Fortunately, this is all that is required to develop any type of Java application. Although other options are available, most others are not as popular as the standard JDK.
However, when you try to download Integrated Development Environments (IDEs) like Eclipse, you are given a range of IDE environments to choose from. Here is where you need to be careful. If you are planning to build only stand-alone applications, then the SE Version, called 'Eclipse for Java Developers' in the case of Eclipse, is your best bet, as it does not bundle unnecessary plugins meant for other environments.
However, if you plan on writing an e-commerce website like Amazon, then you should choose the Enterprise Edition (EE) version, which comes bundled with all the necessary plugins and libraries to help you build a Java Enterprise Edition (JEE) application. This IDE will help you create an EE starter project, build it, and deploy it to a remote web server.
Note:
- You would choose SE if you are purely writing Java programs which are mostly standalone programs running from the command line.
- You would choose EE if you are writing a multi-tier solution, i.e., you can write your application using any or all of the following: HTML, CSS, JavaScript, JSP, JSF, Java, etc. All the relevant files can be placed in the same project folder and the EE tools will help you bundle them appropriately.
SE standards
When you write Java classes to be used as a library by other applications, you can bundle all your classes as a JAR file and then distribute that file to anyone who wishes to use your programs.
- Libraries should be bundled as an
xxx.jarfile, wherexxxis any name you give. - A JAR file is a compressed file, just like a ZIP file.
- If your project depends on other JAR library files, they go in the 'lib' folder.
- All the
.classfiles are in the folders that represent their packages. - An optional
MANIFEST.xmlfile can be added inside theMETA-INFfolder. More details: https://docs.oracle.com/javase/tutorial/deployment/jar/manifestindex.html - Any other file type can also be bundled, like an
xxx.propertiesfile, which typically contains environment variables for the program, anxx.txtfile, or any other binary file.
jar packaging
The JAR package contains all the files mentioned above, but the most important are the .class files that make up the API definition.
This is the simplest of the bundles, and most of the external APIs that we typically use in any project are bundled this way.
JEE Servers


JEE standards
When the Java development environment became popular many decades ago, a lot of open-source server deployment frameworks emerged. Sun Microsystems had provided a set of standards that every server framework group had to follow to be 'J2EE' compatible. This was applicable to Java 2 versions. Subsequently, the Java version moved to 3, 4, etc., and people still called them J2EE standards, which were no longer meant only for Java version 2 but were also applicable to any version. Today, the '2' is dropped, and we just call it 'JEE' compatible.
A JEE project is an extension of an SE project, so it can contain all the files that a JAR file contains, and more. Being 'JEE' compatible means many things, among which the following are important to know:
- Every JEE project should have a
META-INFfolder which contains an optionalMANIFEST.xmlfile. - Every JEE project should have a
WEB-INFfolder that contains the optional Deployment Descriptor fileweb.xml. - All the application configurations beyond the default settings should be added in the
web.xmlfile. - This
web.xmlfile should be inside theWEB-INFfolder as its direct child. - All the libraries referenced in the project should be inside the 'lib' folder.
- The 'lib' folder is directly under the
WEB-INFfolder. - All the Java classes should be under the 'classes' folder, which is a direct child of the
WEB-INFfolder. - The application should be able to connect to a relational database (RDBMS) using suitable JDBC drivers.
- A Web Application should be bundled as an
xxx.warpackage. - Enterprise Applications should be bundled as an
xxx.earpackage.
Where xxx can be any name you give. Although there are three main types of Java packaging ('jar', 'war', and 'ear'), the most popular bundling types are 'jar' and 'war', and in this eBook, we will only focus on them.
war packaging
The 'war' package contains all the files that a JAR can have, like the class files and the META-INF folder, but it should also have a WEB-INF folder, a 'lib' folder inside the WEB-INF folder, and an optional web.xml file inside the WEB-INF folder. Along with these files, you can also bundle HTML, CSS, and JavaScript files which are meant for the client-side interface as well.
One thing to note is that even though the project structure inside Eclipse may not follow the above pattern, it must be in this pattern when the project is packaged and deployed on a web server.
Once you package a web application as 'anyname.war', this package can be deployed on any JEE-compliant web server, and you can expect it to work seamlessly.
The same expectation is applicable for the 'jar' and 'ear' package types as well.