In this recipe, we will make use of the Apache HttpClient (https://hc.apache.org/httpcomponents-client-4.5.x/index.html) library to make a simple HTTP GET request. As we are using Java 9, we want to make use of the module path and not the classpath. Hence, we need to modularize the Apache HttpClient library. One way to achieve this is to use the concept of automatic modules. Let's see how to set up the dependencies for the recipe.
Making an HTTP request using Apache HttpClient
Getting ready
All the required JARs are already present in Chapter10/5_apache_http_demo/mods:
Once these JARs are on the module path, we can declare a dependency on these JARs in module-info.java, which is present in Chapter10/5_apache_http_demo...