• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# How to run the Java demo
2
3## About this document
4
5This document explains how to build and run the demo of the Java version of
6libphonenumber, **from the command line** on **Linux** or **Mac**, using Google
7App Engine. By following the instructions here, you can build a demo running
8against any revision of the Java code by supplying jar files you build on your
9own, or downloading the ones from [Maven
10Central](http://repo1.maven.org/maven2/com/googlecode/libphonenumber/libphonenumber/).
11
12## Detailed steps
13
14### Install Google App Engine
15
16Download and follow [the
17instructions](http://cloud.google.com/appengine/downloads) to install the Java
18SDK of Google App Engine. This document assumes it is named as
19`appengine-java-sdk`. You may want to rename the directory after unpacking.
20
21### Check out the demo code
22
23Check out the Java code:
24
25```
26git clone https://github.com/google/libphonenumber.git
27```
28
29Create a symlink to your unpacked appengine sdk directory at the same level as
30the `java` directory. Alternatively, update `java/demo/build.xml` to point to
31the right location for the appengine sdk.
32
33### Get the phone number library jars
34
35Save the `libphonenumber`, `geocoder`, `carrier`, and `prefixmapper` jars under
36`demo/war/WEB-INF/lib/`.
37
38You can either download them from the  [Maven
39repository](http://repo1.maven.org/maven2/com/googlecode/libphonenumber/) or
40build them yourself by running:
41
42```
43git clone https://github.com/google/libphonenumber.git
44cd libphonenumber/java
45ant jar
46cp build/jar/* demo/war/WEB-INF/lib
47```
48
49### Run the demo code
50
51Start the server:
52
53```
54cd demo
55ant runserver
56```
57
58This will start a server on your localhost, and you can try it out by pointing
59your browser to http://localhost:8080/.
60
61## Troubleshooting
62
63If you get a warning from App Engine asking you to upgrade your JRE to Java 1.6
64or later, you might need to install Java 1.6 and point your `JAVA_HOME` to it.
65
66*   To see your current `JAVA_HOME`, run `echo $JAVA_HOME`.
67*   To see the list of JDKs currently installed, use `update-java-alternatives
68    -l`.
69*   To reset `JAVA_HOME`, use `export JAVA_HOME=[path to Java 1.6 SDK]/jre`.
70
71Now run `ant runserver` to start the server on your localhost.
72
73## Uploading your own demo App Engine application
74
75If you want to upload the demo to your own App Engine application, follow the
76steps to [register an application with App
77Engine](http://cloud.google.com/appengine/docs/standard/java/gettingstarted/deploying-the-application).
78
79Then run:
80
81```
82../appengine-java-sdk/bin/appcfg.sh update war
83```
84
85The demo will be uploaded to `http://application-id.appspot.com/`.
86