LambdaTest Community

Find answers, support, and inspiration from other users

LambdaTest Community

How can I install Maven using command line?

Please someone tell me how can I install Maven using command line.

Up Vote Down Vote 0 Votes
Posted 3 months ago


Here are the steps to install Maven through the command line:

Step 1: Download & Install Java

You need to install Java in your system, if not already done. The latest version of java can be downloaded from this link

To check the java version of your system, please go running and type ‘cmd’ to launch the command prompt. Type ‘Java -version’ and press Enter to see which java version is installed.

Step 2: Set Up Java Environment Variable

After installation of Java, set up the Java Environment Variable. Open the system settings to set the Java Environment Variable.

  • Go to This PC and right-click on the empty space anywhere within and select Properties
  • Click on Advanced System Settings so that a new pop up opens up.
  • Now, from the pop-up window click on Environment Variables
  • Click on the New button under System variables.

  • Type “JAVA_HOME” in the Variable name box and ‘C:\Program Files\Java\jdk1.8.0_20’ JDK path in the Variable value box and save the same.

  • You can now see the newly created Java variable under ‘System Variables’

Step 3: Download Maven and Set Up Maven Environment Variable

  • Maven can be downloaded from the below location:

  • Extract it to some location in your machine as per your convenience. For me it is lying at ‘C:/apache-Maven-3.6.1’
  • You can set up the Maven Environment Variable similar to how we set up the Java Environment Variable in steps above.
  • Type ‘Maven_HOME‘ in the Variable name box and ‘C:\apache-Maven-3.6.1’ in the Variable value box.

  • You’ll now be able to see the newly created Maven variable under ‘System Variables’.

Step 4: Updating the Path Variable

In order to run Maven from the command line, we have to necessarily update the Path Variable with Maven’s installation ‘bin’ directory.

  • Open system properties through My Computer.
  • Navigate to ‘Advanced System Settings’.
  • Click on ‘Environment Variables’.
  • Click on the Edit button under user variables.
  • Type ‘PATH’ in the Variable name box & ‘C:\apache-Maven-3.6.1\bin’ in the Variable value box.

Step 5: Testing the Maven Installation

Maven is now successfully installed in your system. Now let’s verify it from the Windows command line. Open the command prompt and type mvn -version and hit Enter. Check to see the version of Maven installed in your system being displayed in the results.

Now you’re all set with Maven Installation now and can go ahead with creating projects using Maven.

Up Vote Down Vote 0 Votes
Posted 2 months ago