O'Reilly logo

Gradle Effective Implementation Guide by Hubert Klein Ikkink

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Running Java applications

If we want to execute a Java executable from a Gradle build, we have several options. Before we explore these options, we will first create a new Java class with a main() method in our project. We will execute this Java class from our build file.

In the directory src/main/java/gradle/sample, we need to create a new file SampleApp.java. The following code listing shows the contents of the file. We use our Sample class to print the value of the getWelcomeMessage() method to System.out:

// File: src/main/java/gradle/sample/SampleApp.java package gradle.sample; import java.util.ResourceBundle; public class SampleApp { public SampleApp() { } public static void main(final String[] arguments) { final SampleApp app = new SampleApp(); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required