22. Appendices
Here we explain how to install the tools used in this document on Windows 7 or 8 machines. The screenshots generally show the 64-bit versions of the DBMS and tools installed. The reader should adapt to their own environment.
22.1. Installing a JDK
The latest JDK can be found at the URL [http://www.oracle.com/technetwork/java/javase/downloads/index.html] (October 2014). We will refer to the JDK installation directory as <jdk-install> hereafter.
![]() |
22.2. Installing Maven
Maven is a tool for managing dependencies in a Java project and more. It is available (as of October 2014) at the URL [http://maven.apache.org/download.cgi].
![]() |
Download and unzip the archive. We will refer to the Maven installation folder as <maven-install>.
![]() |
- In [1], the file [conf/settings.xml] configures Maven;
It contains the following lines:
<!-- localRepository
| The path to the local repository Maven will use to store artifacts.
|
| Default: ${user.home}/.m2/repository
<localRepository>/path/to/local/repo</localRepository>
-->
The default value on line 4 may cause issues for some software using Maven if, like me, your {user.home} path contains a space (for example, [C:\Users\Serge Tahé]). We will specify (line 7) a different folder for the local Maven repository:
<!-- localRepository
| The path to the local repository Maven will use to store artifacts.
|
| Default: ${user.home}/.m2/repository
<localRepository>/path/to/local/repo</localRepository>
-->
<localRepository>D:\Programs\devjava\maven\.m2\repository</localRepository>
On line 7, avoid using a path that contains spaces.
22.3. Installing STS (Spring Tool Suite)
We will install SpringSource Tool Suite [http://www.springsource.com/developer/sts] (October 2014), an Eclipse environment pre-configured with numerous plugins related to the Spring framework and also with a pre-installed Maven configuration.
![]() |
- Go to the SpringSource Tool Suite (STS) website [1] to download the current version of STS [2A] [2B].
![]() |
![]() |
- The downloaded file is an installer that creates the file directory structure [3A] [3B]. In [4], we launch the executable,
- in [5], the IDE’s workspace window after closing the welcome window. In [6], display the application servers window,
![]() |
- in [7], the servers window. A server is registered. It is a Tomcat-compatible VMware server.
You must specify the Maven installation directory to STS:
![]() |
- in [1-2], configure STS;
- in [3-4], add a new Maven installation;
![]() |
- in [5], specify the Maven installation directory;
- in [6], complete the wizard;
- in [7], set the new Maven installation as the default installation;
![]() |
- In [8-9], you check the local Maven repository, the folder where it will store the dependencies it downloads, and where STS will place the artifacts that are built;
You must also select a JDK (Java Development Kit) to run both Eclipse projects with and without Maven [1-5].
![]() |
With [4], you can add JDKs (Java Development Kits) or JREs (Java Runtime Environments). The JRE can run .class files but cannot compile .java files to produce them. The JDK can do both. You should choose a JDK because certain Maven operations require one.
To create an Eclipse project, proceed as follows:
![]() |
- In [3], give the project a name;
- in [4], select an existing, empty folder;
![]() |
- in [5], the project is created;
- in [5-8], create a package. A package is a folder that contains Java code. Two classes can have the same name if they belong to different packages. Within a project, there cannot be two packages with the same name. Therefore, you cannot use a package name that already exists in one of the project’s dependencies. A company will use a package name that specifies the company, the project, and its various branches;
![]() |
- in [9], give the package a name;
- in [10], the created package;
![]() |
- in [11-13], create a class within the package that was created;
![]() |
- in [14], name the class (must follow the CamelCase convention—each word in the name must start with a capital letter followed by lowercase letters);
- in [15], verify the package;
- in [16], check the box. This requests that the static method [main] be generated. This method makes a class executable, i.e., the first class to be executed in a project;
- in [17], the class thus created;
Type the following code into the [main] method, which displays text on the console:
package st.istia;
public class Test01 {
public static void main(String[] args) {
System.out.println("test01");
}
}
![]() |
- In [18-20], run the class. Its [main] method will then be executed;
![]() |
- in [21-22], the result of the application;
If the [Console] view is not present, proceed as follows [1-4]:
![]() |
When importing an Eclipse project, it may contain errors. This may be due to an incorrect project configuration. To correct the error (if there is one), proceed as follows:
![]() |
- In [1], modify the project's [Build Path];
![]() |
- In [2], the project is configured to use a JVM 1.5;
- In [3], remove this dependency;
- in [4], add a new dependency;
![]() |
- in [5], add a JVM;
- In [6], select the JVM for the machine;
Once this is done, save the changes and then go to the [Java compiler] property of the project [7]:
![]() |
- in [8], instruct the compiler to accept all Java language features up to and including version 1.7 (or 1.8);
- In [9], click OK;
- In [10], the reconfigured project should no longer contain any errors;
Additionally, the imported project can use UTF-8 character encoding. Follow these steps to set this encoding in the imported project [1-4]:
![]() |
Additionally, it may be useful to disable spell checking in the project to prevent French comments from being underlined as incorrect. Follow steps [1-4] below:
![]() |
22.4. Installing the NetBeans IDE
NetBeans is available at [http://netbeans.org/downloads/].
![]() |
You can download the Java SE (Standard Edition) version from the link above.
22.5. Installing the Chrome [Advanced Rest Client] plugin
In this document, we use Google’s Chrome browser (http://www.google.fr/intl/fr/chrome/browser/). We will add the [Advanced Rest Client] extension to it. Here’s how to do it:
- Go to the [Google Web Store] (https://chrome.google.com/webstore) using the Chrome browser;
- Search for the [Advanced Rest Client] app:
![]() |
- The app is then available for download:
![]() |
- To get it, you’ll need to create a Google account. The [Google Web Store] will then ask for confirmation [1]:
![]() |
- In [2], the added extension is available in the [Apps] option [3]. This option appears on every new tab you create (CTRL-T) in the browser.
22.6. JSON Handling in Java
In a way that is trans sparent to the developer, the [Spring MVC] framework uses the [Jackson] JSON library. To illustrate what JSON (JavaScript Object Notation) is, we present here a program that serializes objects into JSON and does the reverse by deserializing the generated JSON strings to recreate the original objects.
The 'Jackson' library allows you to construct:
- the JSON string of an object: new ObjectMapper().writeValueAsString(object);
- an object from a JSON string: new ObjectMapper().readValue(jsonString, Object.class).
Both methods may throw an IOException. Here is an example.
The project above is a Maven project with the following [pom.xml] file;
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>istia.st.pam</groupId>
<artifactId>json</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.3.3</version>
</dependency>
</dependencies>
</project>
- lines 12–16: the dependency that imports the 'Jackson' library;
The [Person] class is as follows:
package istia.st.json;
public class Person {
// data
private String lastName;
private String firstName;
private int age;
// constructors
public Person() {
}
public Person(String lastName, String firstName, int age) {
this.lastName = lastName;
this.firstName = firstName;
this.age = age;
}
// signature
public String toString() {
return String.format("Person[%s, %s, %d]", lastName, firstName, age);
}
// getters and setters
...
}
The [Main] class is as follows:
package istia.st.json;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
public class Main {
// the serialization/deserialization tool
static ObjectMapper mapper = new ObjectMapper();
public static void main(String[] args) throws IOException {
// creating a person
Person paul = new Person("Denis", "Paul", 40);
// Display JSON
String json = mapper.writeValueAsString(paul);
System.out.println("JSON=" + json);
// Instantiate Person from JSON
Person p = mapper.readValue(json, Person.class);
// display Person
System.out.println("Person=" + p);
// an array
Person virginie = new Person("Radot", "Virginie", 20);
Person[] people = new Person[]{paul, virginie};
// Display JSON
json = mapper.writeValueAsString(people);
System.out.println("JSON people=" + json);
// dictionary
Map<String, Person> people = new HashMap<String, Person>();
hpeople.put("1", paul);
hpeople.put("2", virginie);
// Display JSON
json = mapper.writeValueAsString(hpeople);
System.out.println("JSON hpeople=" + json);
}
}
Executing this class produces the following screen output:
Key takeaways from the example:
- the [ObjectMapper] object required for JSON/Object transformations: line 11;
- the [Person] --> JSON transformation: line 17;
- the JSON --> [Person] transformation: line 20;
- the [IOException] thrown by both methods: line 13.
22.7. Installing [WampServer]
[WampServer] is a suite of software for developing in PHP / MySQL / Apache on a Windows machine. We will use it solely for the MySQL DBMS.
![]() |
- On the [WampServer] website [1], choose the appropriate version [2],
- the downloaded executable is an installer. Various pieces of information are requested during installation. They do not concern MySQL, so they can be ignored. Window [3] appears at the end of the installation. Launch [WampServer],
![]() |
- in [4], the [WampServer] icon appears in the taskbar at the bottom right of the screen [4],
- when you click on it, the [5] menu appears. It allows you to manage the Apache server and the MySQL DBMS. To manage the latter, use the [PhpMyAdmin] option,
- which opens the window shown below,

We will provide few details on using [PhpMyAdmin]. In section 6.4.2, we show how to use it to create a database from an SQL script.






























