As we discussed in previous tutorials that Apache maven is Java based project management tool so JDK is the first requirement. Let us discuss step by step maven installation on linux.
Install maven on linux:
- Check Java installation on your machine. Use $ java -version command to verify the java installation. Install the java software development kit if it is not installed.
- Add JAVA_HOME environment variable if it is not added. Export JAVA_HOME=/usr/local/java-current. Export PATH=$PATH:$JAVA_HOME/bin/.
- Download apache maven from here.
- Extract the maven archive file (like apache-maven-3.3.1-bin.tar.gz) to the location where we want to install it. E.g. /usr/local/apache-maven.
- Add maven environment variables. Use command export M2_HOME=/usr/local/apache-maven/apache-maven-3.3.1. Now append the maven bin folder. Use command export PATH=/usr/local/apache-maven/apache-maven-3.3.1/bin.
- Verify maven installation using $ mvn –version command.