File: run-java-demo.md

package info (click to toggle)
libphonenumber 8.12.57%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 99,276 kB
  • sloc: cpp: 52,362; xml: 48,242; javascript: 31,137; java: 29,151; ansic: 482; jsp: 228; sh: 44; makefile: 24
file content (85 lines) | stat: -rw-r--r-- 2,612 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# How to run the Java demo

## About this document

This document explains how to build and run the demo of the Java version of
libphonenumber, **from the command line** on **Linux** or **Mac**, using Google
App Engine. By following the instructions here, you can build a demo running
against any revision of the Java code by supplying jar files you build on your
own, or downloading the ones from [Maven
Central](http://repo1.maven.org/maven2/com/googlecode/libphonenumber/libphonenumber/).

## Detailed steps

### Install Google App Engine

Download and follow [the
instructions](http://cloud.google.com/appengine/downloads) to install the Java
SDK of Google App Engine. This document assumes it is named as
`appengine-java-sdk`. You may want to rename the directory after unpacking.

### Check out the demo code

Check out the Java code:

```
git clone https://github.com/google/libphonenumber.git
```

Create a symlink to your unpacked appengine sdk directory at the same level as
the `java` directory. Alternatively, update `java/demo/build.xml` to point to
the right location for the appengine sdk.

### Get the phone number library jars

Save the `libphonenumber`, `geocoder`, `carrier`, and `prefixmapper` jars under
`demo/war/WEB-INF/lib/`.

You can either download them from the  [Maven
repository](http://repo1.maven.org/maven2/com/googlecode/libphonenumber/) or
build them yourself by running:

```
git clone https://github.com/google/libphonenumber.git
cd libphonenumber/java
ant jar
cp build/jar/* demo/war/WEB-INF/lib
```

### Run the demo code

Start the server:

```
cd demo
ant runserver
```

This will start a server on your localhost, and you can try it out by pointing
your browser to http://localhost:8080/.

## Troubleshooting

If you get a warning from App Engine asking you to upgrade your JRE to Java 1.6
or later, you might need to install Java 1.6 and point your `JAVA_HOME` to it.

*   To see your current `JAVA_HOME`, run `echo $JAVA_HOME`.
*   To see the list of JDKs currently installed, use `update-java-alternatives
    -l`.
*   To reset `JAVA_HOME`, use `export JAVA_HOME=[path to Java 1.6 SDK]/jre`.

Now run `ant runserver` to start the server on your localhost.

## Uploading your own demo App Engine application

If you want to upload the demo to your own App Engine application, follow the
steps to [register an application with App
Engine](http://cloud.google.com/appengine/docs/standard/java/gettingstarted/deploying-the-application).

Then run:

```
../appengine-java-sdk/bin/appcfg.sh update war
```

The demo will be uploaded to `http://application-id.appspot.com/`.