Java Application Sample
version 6.6-rc-5
You can open this sample inside an IDE using the IntelliJ native importer or Eclipse Buildship. |
If you are new to Gradle and wish to follow a more detailed tutorial for building Java applications, we suggest you have an look at the Building Java Applications guide.
This sample shows how a Java application can be built with Gradle. The application has no dependencies and the build has minimal configuration.
build.gradle
plugins {
id 'application'
}
version = '1.0.2'
group = 'org.gradle.sample'
application {
mainClass = 'org.gradle.sample.app.Main'
}
build.gradle.kts
plugins {
application
}
version = "1.0.2"
group = "org.gradle.sample"
application {
mainClass.set("org.gradle.sample.app.Main")
}
To build and run the application:
$ ./gradlew run > Task :run Hello, World! BUILD SUCCESSFUL 2 actionable tasks: 2 executed
For more information, see Application Plugin reference chapter.
You can also generate this project locally using gradle init
.