Java
This guide covers setting up Java development with JDK and Maven.
Installation
We recommend using Amazon Corretto 17, a production-ready distribution of OpenJDK.
- Windows
- macOS
- Linux
# Using winget
winget install Amazon.Corretto.17.JDK
# Or using Chocolatey
choco install corretto17jdk
# Set environment variables (run as Administrator)
[System.Environment]::SetEnvironmentVariable("JAVA_HOME", "C:\Program Files\Amazon Corretto\jdk17", "Machine")
$env:Path += ";$env:JAVA_HOME\bin"
Or download the installer from Amazon Corretto 17.
# Using Homebrew
brew install --cask corretto17
# Add to your shell profile (~/.zshrc or ~/.bashrc)
export JAVA_HOME=$(/usr/libexec/java_home -v 17)
export PATH="$JAVA_HOME/bin:$PATH"
# Reload your shell
source ~/.zshrc
# Ubuntu/Debian
wget -O- https://apt.corretto.aws/corretto.key | sudo apt-key add -
sudo add-apt-repository 'deb https://apt.corretto.aws stable main'
sudo apt-get update
sudo apt-get install -y java-17-amazon-corretto-jdk
# Add to your shell profile (~/.bashrc)
export JAVA_HOME=/usr/lib/jvm/java-17-amazon-corretto
export PATH="$JAVA_HOME/bin:$PATH"
# Reload your shell
source ~/.bashrc
Verify Installation
java -version
Maven
Maven is a build and project management tool primarily used for Java projects. It simplifies dependency management, compilation, testing, and packaging.
Install Maven
- Windows
- macOS
- Linux
# Using winget
winget install Apache.Maven
# Or using Chocolatey
choco install maven
# Set environment variables (run as Administrator)
[System.Environment]::SetEnvironmentVariable("M2_HOME", "C:\Program Files\Apache\maven", "Machine")
$env:Path += ";$env:M2_HOME\bin"
Or download from Maven Downloads and extract to your preferred location.
# Using Homebrew
brew install maven
# Verify installation
mvn -version
# Ubuntu/Debian
sudo apt-get update
sudo apt-get install -y maven
# Or download and install manually
wget https://dlcdn.apache.org/maven/maven-3/3.9.6/binaries/apache-maven-3.9.6-bin.tar.gz
sudo tar -xzf apache-maven-3.9.6-bin.tar.gz -C /opt
sudo ln -s /opt/apache-maven-3.9.6 /opt/maven
# Add to your shell profile (~/.bashrc)
export M2_HOME=/opt/maven
export PATH="$M2_HOME/bin:$PATH"
Verify Installation
mvn -version
Common Maven Commands
# Build project, run tests, create artifacts
mvn package
# Build and install to local repository
mvn install
# Clean build directories
mvn clean
# Run all together
mvn clean install
Set Up Maven with JFrog
- Go to https://p6m.jfrog.io
- Login
- Navigate to Profile → Set Me Up → Maven
- Click Generate Token and Create Instructions
- Click Generate Settings and download the snippet
- Move
settings.xmlto your Maven configuration directory (~/.m2/settings.xmlor%USERPROFILE%\.m2\settings.xmlon Windows)
Related
- Oracle Java Documentation - Official Java documentation
- Maven Configuration - Configure Maven repositories