# How Gradle Works Part 1 - Startup

DevFeed: [How Gradle Works Part 1 - Startup](<https://devfeed.tech/articles/how-gradle-works-part-1-startup-24642.md>)

Original publisher: [Read original article](<https://blog.gradle.org/how-gradle-works-1>)

Author: Bo Zhang

Published: 2023-01-11T02:00:00Z

Content type: tutorial

Language: en

Sources: [The Gradle Blog](<https://devfeed.tech/sources/the-gradle-blog.md>)

Topics: [Gradle](<https://devfeed.tech/topics/gradle.md>), [Command-line interface](<https://devfeed.tech/topics/cli.md>), [Java](<https://devfeed.tech/topics/java.md>), [Shell](<https://devfeed.tech/topics/shell.md>), [Processes](<https://devfeed.tech/topics/processes.md>), [client](<https://devfeed.tech/topics/client.md>), [ide](<https://devfeed.tech/topics/ide.md>)

Tags: [command-line](<https://devfeed.tech/tags/command-line.md>), [gradle](<https://devfeed.tech/tags/gradle.md>), [java](<https://devfeed.tech/tags/java.md>), [process](<https://devfeed.tech/tags/process.md>), [script](<https://devfeed.tech/tags/script.md>)

## AI overview

This introductory tutorial explains how a Gradle build starts when launched from a local distribution or the Gradle Wrapper through the command line or an IDE. It describes the shell script, the lightweight Gradle Client JVM, Gradle Daemon discovery, local-socket communication, input/output forwarding, and the single-JVM exception when build requirements permit it.

## Source excerpt

This is the first blog of a series How Gradle Works, which includes the following topics: How Gradle starts up How many JVMs are involved in a Gradle build What happens in each JVM during the build We'll explain the first topic How Gradle Starts Up in this blog. Before reading on, we assume you are familiar with basic JVM/Gradle concepts (jar, classpath, wrapper, daemon, project, task, etc.). How Gradle Starts Up There are many ways to start a Gradle build: Local Gradle Distribution in CLI: /path/to/local/distribution/bin/gradle <SomeTask> Gradle Wrapper in CLI: ./gradlew <SomeTask> Click a button in your IDE to import a Gradle project or run some tests/tasks What's the difference? What happens under the hood? Before we start, we need to remember that Gradle is software running on top of a JVM (Java Virtual Machine). Local Gradle Distribution in CLI You may have downloaded a Gradle distribution to your local computer, either manually or by some package management tools. Suppose you start a Gradle build by typing /path/to/local/distribution/bin/gradle <SomeTask>. What happens then? Open the /path/to/local/distribution/bin/gradle in your favorite text editor, you'll find that it's nothing magic but a plain text file, or more precisely, a shell script file. When you say /path/to/local/distribution/bin/gradle <SomeTask>, a shell process is started and starts executing the code in the script. At the end of this script, you can see a line: exec "$JAVACMD" "$@" So the script's job is simple: it finds java command, determines the parameters, and starts a JVM by invoking exec. exec executes a command in the same process, i.e. replaces the current process with a JVM process. The entry point of Gradle Client JVM is org.gradle.launcher.GradleMain class. The JVM started by exec is a very lightweight JVM. Let's call it Gradle Client JVM because it doesn't run any real build logic. It searches for a compatible Gradle Daemon and connects to it via a local socket if found. If there