Get started with local development and debugging with IntelliJ IDEA Ultimate Edition and Cloud Tools for IntelliJ. This configuration allows you to run your App Engine app locally in a debug mode and use the development environment's debugger to set breakpoints and step through your code. The Cloud Tools for IntelliJ plugins provide helper functionality for working with App Engine, including deploying apps.
Note that IntelliJ IDEA Ultimate Edition is required to build and run Servlet applications like those for Google App Engine.
Before you begin
- Install the Cloud SDK.
- Install the IntelliJ IDEA prerequisites, which includes Java 8 for the 2016 version or Java 7 for the 2015 version.
- Install IntelliJ IDEA Ultimate Edition (instructions).
- Download and extract the App Engine SDK for Java.
Install Cloud Tools for IntelliJ IDEA
To install the plugins:
- From inside IDEA, open File > Settings. Or, on Mac OS X, open IntelliJ IDEA > Preferences.
- In the navigation pane, select Plugins.
- Click Browse repositories.
- In the dialog that opens, select Google Cloud Tools.
- Click Install.
- Click Close.
- Click OK in the Settings dialog.
- Click Restart.
- Configure the Cloud SDK location:
- Open File > Settings or on Mac OS X open IntelliJ IDEA > Preferences.
- Choose Build, Execution, Deployment > Clouds and select App Engine (BETA).
- Browse to the location where you installed the Cloud SDK. If you aren't
sure where you installed it, you can run
gcloud infoto display its location if you used the interactive installer or added it to your environment's
Create an App Engine project in IntelliJ IDEA
Open IntelliJ IDEA and choose Create New Project.
Select your project's Java SDK or click New to set up a new Java SDK. The Java SDK should be set to Java 7.
From the Additional Libraries and Frameworks list, select the Google App Engine library
In the Google App Engine SDK field, specify the location where you extracted the App Engine SDK.
Provide a name for your project. Click Finish.
You now have a basic project including the App Engine configuration files.
Launch your app in debug mode
Running your app in debug mode in IntelliJ IDEA allows you to set breakpoints in your code. When those lines are executed, processing pauses temporarily, allowing you to inspect your code and step through the execution. This functionality is extremely helpful during development of your app.
To run your app in debug mode:
- Select Run > Debug AppEngine Dev.
- Browse to http://localhost:8080 if IntelliJ does not automatically launch the page for you.
Set a breakpoint and step through your code
Now that you have the debugger running, you can set breakpoints and use them to step through your code execution.
- Place your cursor in a line in your code that you want to be able to start your code inspection.
Select Run > Toggle Breakpoint or press CTRL+F8. You will see a red circle icon next to the line to indicate a breakpoint is set.
Browse your application such that the code with the breakpoint will be executed. In the Debug window, you can inspect the variables that are set at this point in your code execution.
From the Run menu or the Debug window toolbar, you can control the execution of the code to allow you to step through the code. You can choose the Resume Program () option to continue code execution until a different breakpoint is encountered or your code finishes processing.
Deploy your app from IntelliJ IDEA
To deploy your app to the App Engine standard environment:
Choose Tools > Deploy to App Engine.
Configure the server:
Click the ellipsis (...) next to the Server field.
In the Cloud SDK directory field, enter the path to where you installed the Cloud SDK or click the ellipsis to browse to the location.
Specify a project in the Project field.
The first time you configure the tool you will be prompted to sign in to the account associated with the Cloud Platform Console project that you want to deploy.
Click Run to build and deploy your app.
In the Application Servers window, click the name of your project to monitor its deployment progress. If the window is not displaying, click View > Tool Windows > Application Servers.
View your deployed application. The URL of the deployed app prints to the console output or you can view it at:
Now that you have a development environment set up, the following topics can help you get started with App Engine:
- Try out the Hello World sample project on GitHub, which provides a sample application as well as both Gradle and Maven build files.
- Learn to develop and deploy apps in the Cloud Platform Console