Chapter 2. Your first Netty application
This chapter covers
- Setting up the development environment
- Writing an Echo server and client
- Building and testing the applications
In this chapter we’ll show you how to build a Netty-based client and server. The applications are simple—the client sends messages to the server, and the server echoes them back—but the exercise is important for two reasons.
First, it will provide a test bed for setting up and verifying your development tools and environment, which is essential if you plan to work with the book’s sample code in preparation for your own development efforts.
Second, you’ll acquire hands-on experience with a key aspect of Netty, touched on in the previous chapter: building application logic with ChannelHandlers. This will prepare you for the in-depth study of the Netty API we’ll begin in chapter 3.
To compile and run the book’s examples, the only tools you need are the JDK and Apache Maven, both freely available for download.
We’ll also assume that you’re going to want to tinker with the example code and soon start writing your own. Although you can get by with a plain text editor, we strongly recommend the use of an integrated development environment (IDE) for Java.
Your OS may already have a JDK installed. To find out, type the following on the command line: