Monday, July 29, 2013

Installing the Java Software Development Kit (JDK)

The first software package that you need to install for creating Java EE applications is the JDK, which enables you to compile Java source files into binary class files. In addition to the Java compiler, the JDK includes the Java Runtime Environment (JRE), which provides a Java virtual machine that application servers can run on.

The following steps describe how to install the JDK on your development machine. (We will use a Windows 7 machine in these examples; the procedure may be slightly different for other platforms.)
  1. Go to the Oracle Java Downloads page.
  2. Click on Download Java Platform (JDK).
  3. Accept the license agreement.
  4. Choose your platform and download the installer.
  5. Follow the installation wizard and wait for the installation to complete.
Click on Java Platform (JDK)

When the installation completes, follow these steps to set the JAVA_HOME environment variable:
  1. On the Desktop, right-click on Computer, then select Properties.
  2. Click on Advanced System Settings.
  3. If JAVA_HOME is not listed under User variables, click New
  4. In the Variable Name field, type JAVA_HOME. 
  5. In the Variable Value field, type the installation directory of the JDK; for example: C:\Program Files\Java\jdk1.7.0_25
  6. Then click OK.
The Environment Variables window

Setting the JAVA_HOME environment variable

Now follow these steps to add the JDK bin/ directory to your PATH environment variable:

  1. In the Environment Variables window, select Path under System Variables and click Edit.
  2. In the Edit System Variable window, add the bin/ directory of the JDK installation to the Path variable; for example: C:\Program Files\Java\jdk1.7.0_25\bin
  3. Click OK on the Edit System Variable window.
  4. Click OK on the Environment Variables window.
  5. Click OK on the System Properties window.

Setting the Path environment variable

To test that you have set the environment variables correctly, open a new terminal or command prompt window and type the following commands:

>echo %JAVA_HOME%
C:\Program Files\Java\jdk1.7.0_25
>javac -version
javac 1.7.0_25

Your output shoud be similar to the output shown above.

Sunday, July 28, 2013

Set up your environment to create Java EE applications

You need the following tools to develop and test Java EE applications:

  • The Java Software Development Kit (SDK). The SDK is required to compile any Java program, including classes to be included in Java EE applications.
  • A Java EE application server. The application server installed in your development machine helps you test and debug your applications during the development phase.
  • An Integrated Development Environment (IDE). An IDE helps you create and manage Java EE applications as projects. The sophisticated editors provided by most IDEs increase your productivity and enable you to detect errors earlier in the development phase.
  • An IDE plugin for your application server. Some IDE plugins enable you to start and stop the server from the IDE and to view the server log on the IDE window.

In future posts we will describe in detail how to install and use the Oracle Java SDK, the GlassFish application server, and the NetBeans IDE.

Thursday, July 25, 2013

Java EE and application servers, part five

Java EE is a set of specifications that are implemented by many application servers. The server that you choose to run your applications in a production environment depends on factors such as pricing, familiarity, performance, support options, and so on. If you plan to run your Java EE applications on the cloud, you can choose your cloud service provider based on the application server offered by their cloud platform.

If you develop your applications using standard Java EE APIs, you will have more flexibility when choosing an application server or a cloud platform, since your applications will run in any Java EE-compliant server.

The following list contains links to some of the most popular Java EE application servers:

GlassFish Server - An open-source application server sponsored by Oracle
WebLogic Server - A commercial application server sold by Oracle
WildFly - An open-source application server sponsored by RedHat
JBoss - A commercial application server sold by RedHat
TomEE - An open-source application server sponsored by the Apache Foundation
WebSphere - A commercial application server sold by IBM

We will use mostly the GlassFish server in future posts, but we may cover using some other application servers from time to time.

Wednesday, July 24, 2013

Java EE and application servers, part four

Application servers provide a variety of administration interfaces that enable you to:

  • Submit Java EE applications to run in the application server
  • Configure server parameters
  • Create resources such as connection pools, thread pools, and messaging queues

Each application server provides its own tools to perform these tasks. Most application servers provide a web-based administration console and a set of command-line tools. For example, the following figure shows the web administration console for GlassFish, a Java EE application server:

GlassFish web console

We will use administration interfaces for different application servers in future posts.

Tuesday, July 23, 2013

Java EE and application servers, part three

The application server provides applications with a range of services, as illustrated in the following figure:

Main services provided by an application server

The web server handles HTTP requests and responses from and to clients. Your application only needs to indicate at which URLs its web pages and web services should be made available to clients.

The messaging service enables applications to produce and consume messages to communicate between them.

The thread management service provides and manages new threads for applications to execute work. The application server maintains a pool of threads that can be reused, which increases the scalability of applications by using server resources more efficiently.

The injection service enables applications to obtain resources and dependencies automatically at run time. The application server creates and manages the lifecycle of these dependencies (objects), so the application does not have to.

The transaction management service enables applications to define transactional operations and restores the resources associated with a transaction to their original state automatically if an operation cannot be completed entirely.

The authentication service enables applications to manage users and groups and to grant access to some parts of an application only to some users or groups.

The connection pooling service maintains a pool of active connections to a resource (such as a database or a legacy system) that can be reused by applications. Connection pooling improves the performance of applications that use these connections.

The naming directory service enables administrators and applications to register resources (such as connection pools or message queues) in the application server and to access them by their name.

We will learn how to use these services in future posts.

Monday, July 22, 2013

Java EE and application servers, part two

From the previous post, we now understand that a Java EE application cannot run except inside a Java EE application server, and that the application server is a Java program that provides functionality and services to Java EE applications. This scenario is illustrated in the following figure:

Java EE application server

The system administrator starts the application server. As an application developer, you will run an application server in your development machine for testing your applications. While you need to learn the basics of running and configuring an application server, you do not need to become an expert on it. You can subscribe to a Java EE service on the cloud and submit your applications to it, as we will see in future posts.

You can deploy several Java EE applications to an application server. Deploying a Java EE application is like installing that application into the application server and activating it so that it can respond to requests from clients. The configuration settings included in each application tell the application server at what URLs the application should be accessible to clients, among other things.

Sunday, July 21, 2013

Java EE and application servers, part one

Java EE consists of a set of specifications which define:

- The services and functionality that the platform provides to applications
- The APIs that applications use to access these features
- How application servers must implement these features

The Java EE platform defines services and functionality that most web and enterprise applications need; it would not make sense for each application to reinvent the wheel. For example, a social networking site and an online store both need a web server, an authentication framework, a database connectivity engine, and so on.

An application server is a Java program that implements the services and functionality defined by the Java EE specifications. There are many Java EE application servers on the market, some of them available for free. Although some application servers provide additional proprietary functionality, a Java EE application that uses standard features should run in any application server with minor or no modifications.

An important distinction between a Java SE application and a Java EE application is the following: a Java SE application controls the main loop of execution, while a Java EE application does not

Java EE applications do not have a main() method and can only run within an application server, which controls the main loop of execution and invokes the application as required.

What you need to know to create Java EE applications

The previous post gave you an idea of what a Java EE application is and how it fits with the other elements of a complete solution. To take advantage of what the platform has to offer and start building Java EE applications quickly, you need to be somewhat familiar with a few other technologies, such as the following:

- Java SE: You need to be comfortable writing and running Java SE programs. You need to understand the basics of the Java platform: what the virtual machine is, the process for compiling, packaging, and running a Java SE program, and how to use the main Java SE packages in your programs. Although it will help you, being an expert in Java SE is not required to build Java EE applications. We will see why in future posts.

- HTML and CSS: If you want to create applications that are accessed by clients using a web browser, you have to design their interface as HTML pages that are included in your Java EE application. A working knowledge of HTML will help you design these interfaces faster.

- Javascript: For web applications, Javascript enables you to create a more interactive experience for your users by responding to user interface events without reloading pages and by using new features such as the WebSocket protocol.

- The HTTP protocol: Understanding the basics of how the HTTP protocol works helps you make use of some of the features provided by the Java EE APIs when building web applications.

- SQL/Databases: You need to know the basics of database systems and SQL to store and organize the data managed by your application. Java EE provides tools and APIs so that you don't have to deal with database systems directly in your application, but you will benefit from understanding how they work and how to use them at a basic level.

- IDE: You need to be familiar with how to use an Integrated Development Environment. An IDE simplifies developing, packaging, and testing Java EE applications and makes you more productive.

There are plenty of resources available online to learn about these technologies. You will see how these technologies come into play when we build some example applications in future posts.

Friday, July 19, 2013

What applications can you create with Java EE?

The Java EE platform makes it easy for you to create web applications and enterprise applications. For example, you can use Java EE to build on-line stores, web services, social networking sites, news portals, transportation information services, business applications, and back end platforms for smartphone and tablet apps. The possibilities are endless.

In all of the previous examples, Java EE helps you the most with the back end or server-side code. If your application is accessed by clients using a web browser, Java EE also provides you with tools to create dynamic web pages that communicate with the rest of your application. If clients access your application using a native mobile app, you can connect the app and the back end using a standard web service or a socket.

A typical Java EE application looks like this:

A typical Java EE application

Your application contains the following main elements: application logic written in Java classes, dynamic web pages, web service definitions, and entity definitions that need to be persisted in a database (such as a customer, a purchase order, and so on). Your application uses the Java EE APIs to access the services provided by the platform and to communicate with the outside world.

Tuesday, July 16, 2013

Welcome

This blog will explore Java EE and web application development issues, from the basics to new features, including related themes such as application servers, application deployment, patterns, best practices, and platform and industry news.

Cloud computing has made it easy for any developer to create applications and deliver them to millions of client devices without having to know anything about server infrastructure. With infrastructure becoming a service, developers can truly focus on solving business problems and on the requirements of their applications.

Eliminating infrastructure headaches is welcome, but it is not nearly enough. Developers should not just rely on a programming language, but rather use a platform that provides a solid foundation for their applications and enables them to be more productive.

Many developers underestimate the importance of choosing the right platform. There are many concerns to consider: services provided, ease of development, cost, community, reliability, scalability, proven track record, documentation, and so on.

Java EE is an excellent platform for building web and enterprise applications. Java EE is sometimes misunderstood because of its size and complexity, and because its learning curve can be a little steep at first. But don’t let that distract you: the core concepts are not that hard to grasp. Once you understand them, the functionality that Java EE provides becomes easier to use, and development becomes more productive. In many cases, Java EE encourages good code design practices as well.

Just like you can get infrastructure as a service (IaaS), you can also get a platform as a service (PaaS). Cloud computing providers relieve you from the task of installing and configuring the platform on server machines. Several cloud computing providers offer Java EE services. All you have to do is develop your application, configure it, and publish it to the Java EE service provider. Your application becomes available on-line instantly.

Java EE is evolving with the needs of the industry. This blog will follow these developments as they happen. Stay tuned!