Google Code offered in: English - Español - 日本語 - 한국어 - Português - Pусский - 中文(简体) - 中文(繁體)
You develop and upload Java applications for Google App Engine using the App Engine Java software development kit (SDK).
The SDK includes software for a web server that you can run on your own computer to test your Java applications. The server simulates all of the App Engine services, including a local version of the datastore, Google Accounts, and the ability to fetch URLs and send email from your computer using the App Engine APIs.
Google App Engine supports Java 5 and Java 6. When your Java application is running on App Engine, it runs using the Java 6 virtual machine (JVM) and standard libraries. Ideally, you should use Java 6 for compiling and testing your application to ensure that the local server behaves similarly to App Engine.
For developers that don't have easy access to Java 6 (such as developers using Mac OS X), the App Engine SDK is compatible with Java 5. You can upload compiled classes and JARs made with Java 5 to App Engine.
If necessary, download and install the Java SE Development Kit (JDK) for your platform. Mac users, see Apple's Java developer site to download and install the latest version of the Java Developer Kit available for Mac OS X.
Once the JDK is installed, run the following commands from a command prompt (for Windows, Command Prompt; for Mac OS X, Terminal) to verify that you can run the commands, and to determine which version is installed. If you have Java 6 installed, these commands will report a version number similar to 1.6.0
. If you have Java 5 installed, the version number will be similar to 1.5.0
.
java -version javac -version
If you are using the Eclipse development environment, the easiest way to develop, test and upload App Engine apps is to use the Google Plugin for Eclipse. The plugin includes everything you need to build, test and deploy your app, entirely within Eclipse.
The plugin is available for Eclipse versions 3.3, 3.4, 3.5, and 3.6. You can install the plugin using the Software Update feature of Eclipse. The installation locations are as follows:
http://dl.google.com/eclipse/plugin/3.3
http://dl.google.com/eclipse/plugin/3.4
http://dl.google.com/eclipse/plugin/3.5
http://dl.google.com/eclipse/plugin/3.6
For details on how to use Software Update to install the plugin, and how to create a new project, see Using the Google Eclipse Plugin.
If you want to compile and run your application using the command line, or an IDE other than Eclipse, you will need to install something to manage this process. Apache Ant is one such solution. Full directions on installing and setting up Apache Ant to work with App Engine can be found at Using Apache Ant.
If you are using Eclipse and the Google Plugin, you can install the App Engine SDK from Eclipse using Software Update. If you haven't already, install the "Google App Engine Java SDK" component using the locations above.
If you are not using Eclipse or the Google Plugin, you can download the App Engine Java SDK as a Zip archive.
Download the App Engine Java SDK. Unpack the archive in a convenient location on your hard drive.
Note: Unpacking the archive creates a directory whose name is something like appengine-java-sdk-X.X.X
, where X.X.X
is the SDK version number. Throughout this documentation, this directory will be referred to as appengine-java-sdk/
. You may want to rename the directory after unpacking.
The App Engine Java SDK includes several demo applications in the demos/
directory. The final version of the guest book application you will create in this tutorial is included under the directory guestbook/
. This demo has been precompiled for you so you can try it right away.
If you are using Eclipse, the SDK is located in your Eclipse installation directory, under plugins/com.google.appengine.eclipse.sdkbundle_VERSION/
, where VERSION
is a version identifier for the SDK. From the command line, change the current working directory to this directory to run the following command. If you're using Mac OS X or Linux, you may need to give the command files executable permissions before you can run them (such as with the command chmod u+x dev_appserver.sh
).
If you are using Windows, start the guest book demo in the development server by running the following command at a command prompt:
appengine-java-sdk\bin\dev_appserver.cmd appengine-java-sdk\demos\guestbook\war
If you are using Mac OS X or Linux, run the following command:
./appengine-java-sdk/bin/dev_appserver.sh appengine-java-sdk/demos/guestbook/war
The development server starts, and listens for requests on port 8080. Visit the following URL in your browser:
Note: When you start the development server from within Eclipse using the Google Plugin for Eclipse (discussed later), the server uses the port 8888
by default: http://localhost:8888/
For more information about running the development web server from the command line, including how to change which port it uses, see the Dev Web Server reference.
To stop the server, make sure the command prompt window is active, then press Control-C.
The development environment lets you develop and test complete App Engine applications on your computer. Let's start with a simple project.
Continue to Creating a Project.