How to Install Java 8, Apache Maven and Google Web Toolkit on Windows 10

January 13, 2017
Written by
Matt Makai
Twilion

Java, Windows 10, GWT and Apache Maven

Do you want to get started developing Java web applications that use Google Web Toolkit (GWT)? This guide walks through how to install a Windows 10 development environment so you can start building your projects.

Tools We’ll Need

We’ll need to install and configure several tools for our development environment:

Let’s get started by downloading and installing version 8 of the Java JDK.

Java 8 JDK

Head over to the Java 8 JDK downloads page in your web browser. Read and accept the licensing agreement then proceed with the download for the latest release of the Windows x64 Java SE Development Kit.

Java 8 JDK download page.

When the download completes, run the executable. Allow the installer to make changes to your system.
Move through the installer and when you reach the following screen press the “Change…” button.
Change JDK installation directory.

Modify the installation directory to C:\devel\Java\jdk180_112 (or modify the numbers based on the security release version you downloaded). Generally, it is easier to work with Java on the command line if there are no spaces in the directory names.
Change JDK installation directory.

Remember to change the JRE installation directory to somewhere without spaces.
Change JRE installation directory.

Finish the installation process. Java will be added to your PATH environment variable but we also need to set JAVA_HOME. Within the search box in the Windows Start menu, search for the term “environment variables” and click on the System Properties result to open the System Properties panel. Click the “Environment Variables…” button to open the Environment Variables settings panel. Add a new System environment variable named JAVA_HOME with the value of the base directory to your Java 8 JDK installation (not the bin subdirectory).
Set JAVA_HOME under environment variables.

In this case, I installed the JDK to C:\devel\Java\jdk180_112. I set that as the value of JAVA_HOME. Keep the System Environment Variables panel open because we will need it soon when we install Maven and GWT.
Test that our installation proceeded correctly by opening up the command prompt. Search for “cmd” in the taskbar search menu.
Command prompt search.

Type java -version and press enter.

C:\devel>java -version
java version "1.8.0_112"
Java(TM) SE Runtime Environment (build 1.8.0_112-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.112-b15, mixed mode)

You should see the exact Java version you just installed. That means you are good to go with the JDK.

Now that we have the Java JDK properly installed we move on to setting up Maven for our project builds and dependency management.

Apache Maven

Open up the Apache Maven download page and grab the “binary zip archive”.
After the file finishes downloading, open it using File Explorer. Copy the directory within the zip file into your  C:\devel folder.
Add  C:\devel\apache-maven-3.3.9\bin (or the directory of the specific version you downloaded) as a value in your  PATH system environment variable.

Add Maven to PATH environment variable.

Environment variable changes, such as this one to the PATH variable, only take effect within new command prompt windows so re-open the command prompt.
Run  mvn -version while not currently in the Maven installation directory. You should see output similar to the following text.

C:\devel>mvn -version
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T08:41:47-08:00)
Maven home: C:\devel\apache-maven-3.3.9\bin\..
Java version: 1.8.0_112, vendor: Oracle Corporation
Java home: C:\devel\Java\jdk180_112\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "dos"

If you instead receive an error stating that the  mvn command cannot be found, double check that Maven’s  bin directory was correctly set in the PATH variable.
Now that the Java JDK and Maven are configured we can move on to installing GWT.

Google Web Toolkit (GWT)

Download GWT and extract the folder into  C:\devel, just as we did with Java and Maven.
All we have to do with GWT is add the base GWT directory to our PATH environment variable. Open the System Properties and Environment Variables panel back up and add the GWT installation directory, such as C:\devel\gwt-2.8.0, as a value.
Test out the configuration by closing all of your command prompt windows and opening a new one. Make sure your current directory is outside the GWT directory and type webAppCreator, one of GWT’s important commands that creates new projects. If GWT was added to the PATH correctly then the output should look like the following text.

C:\devel>webAppCreator
Missing required argument 'moduleName'                                                                                  Google Web Toolkit 2.8.0
WebAppCreator [-[no]overwriteFiles] [-[no]ignoreExistingFiles] [-templates template1,template2,...] [-out dir] [-junit pathToJUnitJar] [-[no]maven] [-[no]ant] moduleName

where
  -[no]overwriteFiles       Overwrite any existing files. (defaults to OFF)
  -[no]ignoreExistingFiles  Ignore any existing files; do not overwrite. (defaults to OFF)
  -templates                Specifies the template(s) to use (comma separeted). Defaults to 'sample,ant,eclipse,readme'
  -out                      The directory to write output files into (defaults to current)
  -junit                    Specifies the path to your junit.jar (optional)
  -[no]maven                DEPRECATED: Create a maven2 project structure and pom file (default disabled). Equivalent to specifying 'maven' in the list of templates. (defaults to OFF)
  -[no]ant                  DEPRECATED: Create an ant configuration file. Equivalent to specifying 'ant' in the list of templates. (defaults to OFF)
and
  moduleName                The name of the module to create (e.g. com.example.myapp.MyApp)

We can now create our first GWT web application project. Create a new directory for our project named firstProject (or the name you want for your own project) with the mkdir command, then move into that directory with cd:

mkdir firstProject
cd firstProject

Type the following command within the C:\devel\firstProject directory to create the boilerplate code for the GWT project.

C:\devel>webAppCreator
Missing required argument 'moduleName'                                                                                  Google Web Toolkit 2.8.0
WebAppCreator [-[no]overwriteFiles] [-[no]ignoreExistingFiles] [-templates template1,template2,...] [-out dir] [-junit pathToJUnitJar] [-[no]maven] [-[no]ant] moduleName

where
  -[no]overwriteFiles       Overwrite any existing files. (defaults to OFF)
  -[no]ignoreExistingFiles  Ignore any existing files; do not overwrite. (defaults to OFF)
  -templates                Specifies the template(s) to use (comma separeted). Defaults to 'sample,ant,eclipse,readme'
  -out                      The directory to write output files into (defaults to current)
  -junit                    Specifies the path to your junit.jar (optional)
  -[no]maven                DEPRECATED: Create a maven2 project structure and pom file (default disabled). Equivalent to specifying 'maven' in the list of templates. (defaults to OFF)
  -[no]ant                  DEPRECATED: Create an ant configuration file. Equivalent to specifying 'ant' in the list of templates. (defaults to OFF)
and
  moduleName                The name of the module to create (e.g. com.example.myapp.MyApp)

GWT’s  webAppCreator command just built a new project with the necessary project structure to use Maven as our build tool.
Test that Maven works with the GWT project. Enter the following command from within the  firstProject base directory where the  pom.xml file was generated:

mvn compile

There will be a slew of output while Maven downloads the appropriate project build dependencies. Maven should conclude with a  BUILD SUCCESS message like this one:

INFO] Changes detected - recompiling the module!
[INFO] Compiling 5 source files to C:\devel\firstProject\target\firstProject-1.0-SNAPSHOT\WEB-INF\classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 24.297 s
[INFO] Finished at: 2017-01-09T17:24:27-08:00
[INFO] Final Memory: 24M/171M
[INFO] ------------------------------------------------------------------------

Now the project is ready for developing GWT applications.

Ready for Java Development!

You’re all set to get cranking building your GWT app now that your local development environment is configured. Next you will want to take a look at the Twilio Voice, Twilio SMS and TaskRouter Java quickstarts to add communications into your new application.

Questions or comments? Contact me via