# Chapter 33. The Application Plugin

The Gradle application plugin extends the language plugins with common application related tasks. It allows running and bundling applications for the jvm.

## 33.1. Usage

To use the application plugin, include in your build script:

Example 33.1. Using the application plugin

`build.gradle`

    apply plugin:'application'

To define the main-class for the application you have to set the `mainClassName` property as shown below

Example 33.2. Configure the application main class

`build.gradle`

    mainClassName = "org.gradle.sample.Main"

Then, you can run the application by running `gradle run`. Gradle will take care of building the application classes, along with their runtime dependencies, and starting the application with the correct classpath.

The plugin can also build a distribution for your application. The distribution will package up the runtime dependencies of the application along with some OS specific start scripts. You can run `gradle install` to create an image of the application in `build/install/`projectName``. You can run `gradle distZip` to create a ZIP containing the distribution.

## 33.2. Tasks

The Application plugin adds the following tasks to the project.

Table 33.1. Application plugin - tasks

Task name | Depends on | Type | Description
`run` | `classes` | `JavaExec` | Starts the application.
`startScripts` | `jar` | `CreateStartScripts` | Creates OS specific scripts to run the project as a JVM application.
`install` | `jar`, `startScripts` | `Sync` | Installs the application into a specified directory.
`distZip` | `jar`, `startScripts` | `Zip` | Creates a full distribution ZIP archive including runtime libraries and OS specific scripts.

## 33.3. Convention properties

The application plugin adds some properties to the project, which you can use to configure its behaviour. See `Project`.