labs / tiddlers / content / labs / lab01 / _labs_lab01_Exercise_ Exploring

As you may remember from INFO201, NetBeans is just a fancy code editor. NetBeans delegates to a build tool to compile and run your projects. There are a bunch of build tools available for Java, and NetBeans supports several of them (Maven, Ant, and Gradle) — we will be using Gradle, since it is the most modern of the available tools. Maven and Gradle are the dominant build tools that you are likely to encounter when working with Java.

Let's take a closer look at the Gradle build file. Expand <

> in the project pane. You will see the <> file that NetBeans generated for you when you created the project.

Delete all of the code in that file and replace it with the following:

plugins {
   id 'java'

This is the bare minimum that we need to create a Java project using Gradle. Gradle supports many other programming languages and environments, so we at least need to tell what environment we are using so that it knows how to compile the code &mdash in this case, Java.

You should still be able to run your Main class to display the 'hello world' message.

Gradle has a default project layout, so as long as your files are using this default layout, this minimal build file is enough to allow Gradle to find and compile your code.

You can read about the default project layout at:

Since we are sticking to the default project layout, all we need in this file is to tell Gradle which sort of project we want — in this case a Java project.