How to create Gradle Java Project using Intellij IDEA?

Step by Step Project creation.

  • Open Intellij IDEA

  • Click File >> Project OR Create New Project (if new installation)

Create Java Gradle Project with Intellij IDEA
  • Click Gradle >> Check to Java >> Press Next

Create Java Gradle Project with Intellij IDEA Step 2
  • Fill Text box, GroupId and ArtifactId >> Press Next

Create Java Gradle Project with Intellij IDEA Step 3
  • Press Next

Create Java Gradle Project with Intellij IDEA Step 4
  • Enter the Project name and Project save Location >> Press Finish

Create Java Gradle Project with Intellij IDEA Step 5
  • Wait Until Finish the Gradle Download process

Create Java Gradle Project with Intellij IDEA Step 6
  • After dependencies download gradle project structure will be like below

Create Java Gradle Project with Intellij IDEA Step 7
  • Description of Gradle Project Directory Structure

    • gradle : This is the Gradle Wrapper, which help to run gradle project.

    • src >> main >> java : This is the main java source.

    • src >> main >> resources : This is the main java resource directory.

    • src >> test >> java : This is the test java source. which need if we want to create test classes.

    • src >> test >> resources : This is the test java resource directory.

    • .gitignore : It’s file/directory Ignore list for git (VCS)

    • build.gradle : Build file is heart of gradle project. here everything listed, like dependency, plugin, repositories etc

    • gradlew : Bash script which allow to run gradle command.

    • gradlew.bat : Batch script which allow to run gradle command in windows environment

    • settings.gradle : Project name, and other configuration

  • Let’s Create a Java package. Flow the instruction. Right Click top of java >> New >> Click to Package.

Create Java Gradle Project with Intellij IDEA Step 8
  • Put the package name >> Press OK. In my case i put the package name, com.hmtmcse

Create Java Gradle Project with Intellij IDEA Step 9
  • Adding new Class, Right Click top of com.hmtmcse (my case) >> New >> Click of Java Class.

Create Java Gradle Project with Intellij IDEA Step 10
  • Enter The Class Name >> Press Ok (My case the class name is Bismilla)

Create Java Gradle Project with Intellij IDEA Step 11
  • Right Click on Editor >> Press to Run

Create Java Gradle Project with Intellij IDEA Step 12
  • Class Codes

public class Bismillah {

    public static void main(String[] args) {
        System.out.println("Bismillah Gradle Project");
    }
}
  • Output of the codes

Create Java Gradle Project with Intellij IDEA Step 2


YouTub Video Tutorial for gradle Java Project Creation.