Getting started with the Micronaut framework
In order to get started with the Micronaut framework, we will begin by installing the Micronaut CLI on Mac and Windows OS.
Installing the Micronaut CLI on mac OS
On mac OS, we can install the Micronaut CLI in a couple of ways – using SDKMAN!, Homebrew, or MacPorts. In the following sections, we will cover step-by-step instructions to install the Micronaut CLI.
Installing Micronaut using SDKMAN!
Please follow these steps to install the Micronaut CLI using SDKMAN!:
- Open Terminal.
- If you don't have SDKMAN! installed, take the following steps:
a. Type or paste the following command:
curl -s https://get.sdkman.io | bash
b. Next, type or paste the following command:
source "$HOME/.sdkman/bin/sdkman-init.sh"
- To install the Micronaut CLI, type or paste the following command:
source sdk install micronaut
You will observe the following interactions on Terminal while installing the Micronaut CLI:
- If all the preceding steps execute successfully, you can verify the Micronaut CLI installation by running the following command in Terminal:
mn -version
Installing Micronaut using Homebrew
Please follow these steps to install the Micronaut CLI using MacPorts:
- Open Terminal.
- If you don't have Homebrew installed, then take the following steps:
a. Type or paste the following command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
b. Next, type or paste the following command:
brew update
- Type or paste the following command:
brew install micronaut
You will observe the following interactions on Terminal while installing the Micronaut CLI:
- If all the preceding steps execute successfully, you can verify the Micronaut CLI installation by hitting the following command in Terminal:
mn -version
Installing Micronaut using MacPorts
Please follow these steps to install the Micronaut CLI using Homebrew:
- If you don't have MacPorts installed, then follow the instructions at https://www.macports.org/install.php.
- Open Terminal.
- Type or paste the following command:
sudo port sync
- Type or paste the following command:
sudo port install micronaut
You will observe the following interactions on Terminal while installing the Micronaut CLI:
- If all the preceding steps execute successfully, you can verify the Micronaut CLI installation by hitting the followed command in Terminal:
mn -version
Installing the Micronaut CLI on Windows
Please follow these steps to install the Micronaut CLI on Windows:
- Download the Micronaut CLI binary from the Micronaut download page: https://micronaut.io/download.html.
- Unzip the downloaded binary file into a folder on your system. It is better to keep this in a separate folder under a root directory such as
C:\Program Files\Micronaut
. - Create a new system variable called
MICRONAUT_HOME
with the preceding directory path. Please note to add this variable under system variables (not user variables). - Then, update your Windows
PATH
environment variable. You can add a path such as%MICRONAUT_HOME%\bin
. - Open Command Prompt or any terminal and type the following command:
mn
This will boot up the CLI for the first time by resolving any dependencies.
- To test that the CLI is installed properly, type the following command:
mn – h
This is what the command outputs:
- You should see all the CLI options after hitting the preceding command.
In this section, we explored different ways to install the Micronaut CLI in Windows and macOS. In order to get hands-on with the Micronaut framework, we will get started with working on a hello world project in the next section.