- Check if Java is Already Installed: To determine if Java is already installed on your system, open a terminal or command prompt and run the following command:
java -version
If you see a Java version displayed, it means Java is already installed. You can skip to the Maven installation section.
- Install Java: If Java is not installed, you can download and install it from the official Oracle website or use OpenJDK, which is an open-source alternative.
-
Oracle Java (Note: Requires Oracle account): Visit the Oracle Java Downloads page and download the Java SE Development Kit (JDK) for your operating system. Follow the installation instructions for your platform.
-
OpenJDK (Linux/macOS): On Linux and macOS, you can install OpenJDK using package managers like
apt
(for Debian/Ubuntu) orbrew
(for macOS).For Debian/Ubuntu:
sudo apt update sudo apt install openjdk-11-jdk
For macOS (using Homebrew):
brew tap AdoptOpenJDK/openjdk brew install adoptopenjdk11
-
OpenJDK (Windows): You can download OpenJDK for Windows from the AdoptOpenJDK website and follow the installation instructions.
- Verify Java Installation: To verify that Java has been successfully installed, run the following command again:
java -version
-
Download Maven: Visit the Apache Maven Download page and download the latest stable version of Apache Maven. Choose the binary zip archive for your operating system.
-
Install Maven:
- Extract the downloaded zip archive to a location on your system.
- Add the
bin
directory of the extracted Maven folder to your system's PATH environment variable. This allows you to run Maven from any directory in your terminal.
- Verify Maven Installation: Open a new terminal window and run the following command to verify that Maven has been successfully installed:
mvn -version
You should see Maven version information.
$ mvn clean install