Chapter 18. Examples for Chapter 3

Chapter 3 walked you through a very basic example of creating a JAX-RS service and a JAX-RS client that invokes on it. This service was a simple in-memory customer database. It was modeled as a singleton JAX-RS resource class and exchanged simple XML documents.

This chapter takes the code from Chapter 3 and shows you how to run it using the downloadable workbook example code. I’ll walk you through how the code is structured on disk as well as how the examples use the Maven build system to compile, build, and run it.

Build and Run the Example Program

Perform the following steps:

  1. Open a command prompt or shell terminal and change to the ex03_1 directory of the workbook example code.
  2. Make sure your PATH is set up to include both the JDK and Maven, as described in Chapter 17.
  3. Perform the build by typing mvn install. Maven uses pom.xml to figure out how to compile, build, and run the example code.

Before we examine the build file for this example, you might want to take a quick look at the Maven utility at its Apache website.

Maven is a build-by-convention tool. It expects that your source code be laid out in a certain directory structure. From this standard directory structure, it knows how to automatically find, compile, and package your main class files. It also knows where your test code is and will compile and run it.

Every exercise in this book will follow the directory structure shown in Figure 18-1. Table 18-1 describes the purpose of ...

Get RESTful Java with JAX-RS 2.0, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.