Book Image

Java 9 Programming By Example

By : Peter Verhas
Book Image

Java 9 Programming By Example

By: Peter Verhas

Overview of this book

This book gets you started with essential software development easily and quickly, guiding you through Java’s different facets. By adopting this approach, you can bridge the gap between learning and doing immediately. You will learn the new features of Java 9 quickly and experience a simple and powerful approach to software development. You will be able to use the Java runtime tools, understand the Java environment, and create Java programs. We then cover more simple examples to build your foundation before diving to some complex data structure problems that will solidify your Java 9 skills. With a special focus on modularity and HTTP 2.0, this book will guide you to get employed as a top notch Java developer. By the end of the book, you will have a firm foundation to continue your journey towards becoming a professional Java developer.
Table of Contents (17 chapters)
Title Page
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Running the Jetty web servlet


Since we have included the Jetty plugin into our Gradle build, the targets of the plugin are available. To start Jetty is as easy as typing the following:

gradle jettyRun

This will compile the code, build the WAR file, and start the Jetty servlet container. To help us remember, it also prints the following on the command line:

Running at http://localhost:8080//hello

We can open this URL and see the opening screen of the game with the colors that the program created as a first guess:

Now it is time to have some fun and play with our game, giving answers to the program. Do not make it easy for the code! Refer to the following screenshot:

At the same time, if you look at the console where you have typed gradle jettyRun, you will see that the code is printing out log messages, as shown in the following screenshot:

These printouts come through the logger that we have in our code. In the previous chapters, we used the System.out.println method calls to send informational...