Installing Liquibase with Maven on Linux/Unix/Mac/Windows

To download Maven for Linux, Unix, or Mac, go to https://maven.apache.org/download.cgi and select the Binary tar.gz archive download file to install the latest version of Apache Maven.

To download Maven for Windows, go to https://maven.apache.org/download.cgi and select the Binary zip archive download file to install the latest version of Apache Maven.

Installing Maven on Linux, Unix, or Mac

Once you have downloaded the .tar.gz file, extract it to a new local directory on your computer.

Example: /usr/apps/apache-maven-3.6.2/bin

Next, add the apache-maven-3.6.2/bin directory to your PATH. To add the directory to your PATH:

  1. Open the Terminal or Linux Command Line.
  2. Run the following command:
export PATH=$PATH:/usr/apps/apache-maven-3.6.2/bin

Note: This command will not permanently update your PATH. To permanently update your PATH, edit your ~/.profile or ~/.bashrc file, add the export command as it is shown in step 2, and then run either source ~/.profile or source ~/.bashrc.

Installing Maven on Windows

Once you have downloaded the .zip file, extract it to a new local directory on your computer.

Example: C:\apps\apache-maven-3.6.2\bin

Next, add the new directory with the file to your PATH. To add the directory to your PATH:

  1. In your Windows search box, type env and select the Edit the System Environment option in the Control Panel.
  2. In the Advanced tab, click Environment Variables.
  3. In the System Variables section, click the Path variable, and then click Edit.
  4. In the Edit environment variable window, select New and add the path to the Maven installation directory.
  5. Select OK on all windows to close them.

Verifying changes

Verification is a part of the Maven installation process, and you need to check the following:

  1. The apache-maven-3.6.2 folder was correctly added to your PATH.
  2. Java is installed on your system.
  3. Maven can be run.

Verification #1: Check your path

To verify that you have correctly added the apache-maven-3.6.2/bin folder to your PATHs on Linux, Unix, or Mac, type env in your Terminal or Linux Command Line to display all your available PATHs. Verify that the path you added is shown.

To verify that you have correctly added the apache-maven-3.6.2\bin folder to your PATHs on Windows:

  1. Type power in your Windows search box and select Windows PowerShell.
  2. In the PowerShell window, type $env:PATH.
  3. Verify that the path you added is shown.

Verification #2: Check for Java installation

For Maven to run correctly, you must have Java on your Windows, Linux, Unix, or Mac machine.

To verify that Java is installed on your computer (Linux, Unix, or Mac):

  1. Open your Terminal or Linux Command Line.
  2. Type java -version. If you see the error message "-bash: java: command not found", then you need to either install Java, or you need to add the location of the Java executable to your PATH.

Note: To install Java on your computer, go to https://www.oracle.com/java/technologies/javase-downloads.html. Add the location of the Java file to your PATH environment as a variable. For more information, see .

To verify that Java is installed on your computer (Windows):

  1. In your Windows search box, type cmd to open the Command Prompt.
  2. Type java.exe -version. If you see the error message "'java' is not recognized as an internal or external command, operable program or batch file" or "java : The term 'java' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again", then you need to install Java.

Note: To install Java on your computer, go to https://www.oracle.com/java/technologies/javase-downloads.html. Add the location of the Java file to your PATH environment as a variable. For more information, see .

Verification #3: Run Maven

Finally, verify that Maven is working correctly. To run the command:

  1. Open your Terminal, Linux Command Line, or Command Prompt.
  2. Type mvn –v. You should see a similar output:
Apache Maven 3.6.2 (40f52333136460af0dc0d7232c0dc0bcf0d9e117; 2019-08-27T17:06:16+02:00)
Maven home: /opt/apache-maven-3.6.2
Java version: 1.8.0_45, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.8.5", arch: "x86_64", family: "mac"

Next steps - using Liquibase in a Maven project

  1. Getting Started with Liquibase and Maven: learn how to configure Liquibase Open Source or Liquibase Pro with your Maven installation
  2. Setting up a Liquibase project with Maven and PostgreSQL: see an example configuration with PostgreSQL

Related links