11767c5feSopenharmony_ci# How to run the Java demo 21767c5feSopenharmony_ci 31767c5feSopenharmony_ci## About this document 41767c5feSopenharmony_ci 51767c5feSopenharmony_ciThis document explains how to build and run the demo of the Java version of 61767c5feSopenharmony_cilibphonenumber, **from the command line** on **Linux** or **Mac**, using Google 71767c5feSopenharmony_ciApp Engine. By following the instructions here, you can build a demo running 81767c5feSopenharmony_ciagainst any revision of the Java code by supplying jar files you build on your 91767c5feSopenharmony_ciown, or downloading the ones from [Maven 101767c5feSopenharmony_ciCentral](http://repo1.maven.org/maven2/com/googlecode/libphonenumber/libphonenumber/). 111767c5feSopenharmony_ci 121767c5feSopenharmony_ci## Detailed steps 131767c5feSopenharmony_ci 141767c5feSopenharmony_ci### Install Google App Engine 151767c5feSopenharmony_ci 161767c5feSopenharmony_ciDownload and follow [the 171767c5feSopenharmony_ciinstructions](http://cloud.google.com/appengine/downloads) to install the Java 181767c5feSopenharmony_ciSDK of Google App Engine. This document assumes it is named as 191767c5feSopenharmony_ci`appengine-java-sdk`. You may want to rename the directory after unpacking. 201767c5feSopenharmony_ci 211767c5feSopenharmony_ci### Check out the demo code 221767c5feSopenharmony_ci 231767c5feSopenharmony_ciCheck out the Java code: 241767c5feSopenharmony_ci 251767c5feSopenharmony_ci``` 261767c5feSopenharmony_cigit clone https://github.com/google/libphonenumber.git 271767c5feSopenharmony_ci``` 281767c5feSopenharmony_ci 291767c5feSopenharmony_ciCreate a symlink to your unpacked appengine sdk directory at the same level as 301767c5feSopenharmony_cithe `java` directory. Alternatively, update `java/demo/build.xml` to point to 311767c5feSopenharmony_cithe right location for the appengine sdk. 321767c5feSopenharmony_ci 331767c5feSopenharmony_ci### Get the phone number library jars 341767c5feSopenharmony_ci 351767c5feSopenharmony_ciSave the `libphonenumber`, `geocoder`, `carrier`, and `prefixmapper` jars under 361767c5feSopenharmony_ci`demo/war/WEB-INF/lib/`. 371767c5feSopenharmony_ci 381767c5feSopenharmony_ciYou can either download them from the [Maven 391767c5feSopenharmony_cirepository](http://repo1.maven.org/maven2/com/googlecode/libphonenumber/) or 401767c5feSopenharmony_cibuild them yourself by running: 411767c5feSopenharmony_ci 421767c5feSopenharmony_ci``` 431767c5feSopenharmony_cigit clone https://github.com/google/libphonenumber.git 441767c5feSopenharmony_cicd libphonenumber/java 451767c5feSopenharmony_ciant jar 461767c5feSopenharmony_cicp build/jar/* demo/war/WEB-INF/lib 471767c5feSopenharmony_ci``` 481767c5feSopenharmony_ci 491767c5feSopenharmony_ci### Run the demo code 501767c5feSopenharmony_ci 511767c5feSopenharmony_ciStart the server: 521767c5feSopenharmony_ci 531767c5feSopenharmony_ci``` 541767c5feSopenharmony_cicd demo 551767c5feSopenharmony_ciant runserver 561767c5feSopenharmony_ci``` 571767c5feSopenharmony_ci 581767c5feSopenharmony_ciThis will start a server on your localhost, and you can try it out by pointing 591767c5feSopenharmony_ciyour browser to http://localhost:8080/. 601767c5feSopenharmony_ci 611767c5feSopenharmony_ci## Troubleshooting 621767c5feSopenharmony_ci 631767c5feSopenharmony_ciIf you get a warning from App Engine asking you to upgrade your JRE to Java 1.6 641767c5feSopenharmony_cior later, you might need to install Java 1.6 and point your `JAVA_HOME` to it. 651767c5feSopenharmony_ci 661767c5feSopenharmony_ci* To see your current `JAVA_HOME`, run `echo $JAVA_HOME`. 671767c5feSopenharmony_ci* To see the list of JDKs currently installed, use `update-java-alternatives 681767c5feSopenharmony_ci -l`. 691767c5feSopenharmony_ci* To reset `JAVA_HOME`, use `export JAVA_HOME=[path to Java 1.6 SDK]/jre`. 701767c5feSopenharmony_ci 711767c5feSopenharmony_ciNow run `ant runserver` to start the server on your localhost. 721767c5feSopenharmony_ci 731767c5feSopenharmony_ci## Uploading your own demo App Engine application 741767c5feSopenharmony_ci 751767c5feSopenharmony_ciIf you want to upload the demo to your own App Engine application, follow the 761767c5feSopenharmony_cisteps to [register an application with App 771767c5feSopenharmony_ciEngine](http://cloud.google.com/appengine/docs/standard/java/gettingstarted/deploying-the-application). 781767c5feSopenharmony_ci 791767c5feSopenharmony_ciThen run: 801767c5feSopenharmony_ci 811767c5feSopenharmony_ci``` 821767c5feSopenharmony_ci../appengine-java-sdk/bin/appcfg.sh update war 831767c5feSopenharmony_ci``` 841767c5feSopenharmony_ci 851767c5feSopenharmony_ciThe demo will be uploaded to `http://application-id.appspot.com/`. 86