Run Liquibase Without Launch Scripts

Liquibase comes with a launch script called liquibase/liquibase.bat, which configures Java to run the Liquibase launcher through your command line interface (CLI). This batch script is the default and recommended way to run Liquibase via CLI.

However, if you want to use Liquibase without calling the launcher, you can make a direct Java call in your command line.


When run, the liquibase.bat launch script does the following:

  1. Chooses the correct version of Java:
    1. If you already set the JAVA_HOME environment variable, the launch script uses the Java version there
    2. Otherwise, if you installed the CLI via an installer, the launch script uses the Java version bundled with the version of Liquibase you installed
    3. Otherwise, the launch script uses the Java version configured in the PATH environment variable
  2. Sets the classpath to include liquibase.jar, the contents of ./liquibase_libs, and the contents of LIQUIBASE_HOME/lib.
  3. Includes any additional Java arguments set in the JAVA_OPTS Environment Variable
  4. Runs the liquibase.integration.commandline.LiquibaseCommandLine class

Note: For more information, see How Liquibase Finds Files: Liquibase Search Path.

Run Liquibase without the launcher

If you don't want to run liquibase.bat, you can make a direct Java call that does the same thing as the launch script. In your command line, run the java command and set your classpath with the -cp flag. Then run the LiquibaseCommandLine class to start Liquibase in the CLI, followed by the command you would normally enter in the CLI if you had launched it with liquibase.bat:

java -cp <your classpath> liquibase.integration.commandline.LiquibaseCommandLine <liquibase args>

For example:

java -cp /Users/example/liquibase liquibase.integration.commandline.LiquibaseCommandLine update --changelog-file=foobar.xml

Note: Liquibase does not support java -jar liquibase.jar because Java does not allow both -jar and -cp to be set, and you need control over the classpath to correctly configure Liquibase to run.

Related links