How do I install third-party libraries in Maven repository?

Sometimes when the required libraries / dependencies is not available in the Maven Central Repository we need to manually install it to our local repository. This library must be placed in the correct directory in our local repository to enable Maven to find it. The default location is under the ${user.home}/.m2/repository.

To make this job easier Maven provide a maven-install-plugin that will help us to install the third-party library in the correct place. The following command shows how to do it.

The long command

mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> \
        -DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>


  • -Dfile = path to the third-party library file
  • -DgroupId = the groupId of the library
  • -DartifactId = the artifactId of the library
  • -Dversion = the version number of the library
  • -Dpackaging = the library packaging

An example to install an Oracle JDBC library to your local repository is:

mvn install:install-file -Dfile=ojdbc7.jar \
        -DartifactId=ojdbc7 -Dversion= -Dpackaging=jar

The simple command

If you have the pom.xml file, you can install it with the following command:

mvn install:install-file \
        -Dfile=<path-to-file> \


  • -Dfile = path to the third-party library file
  • -DpomFile = the location to the library pom.xml file

Starting with the Maven version 2.5 you can use even a simpler command. When the library is build by Maven, a pom.xml file will be placed under the META-INF directory. This pom.xml file will be used by default when we install the library. To install a library all you need is the following command:

mvn install:install-file -Dfile=<path-to-file>

How do I run FTP server in Mac OS X?

I need to test FTP client codes, so I need to find an FTP server for testing my codes. After searching for a while I find out that OS X already equipped FTP server. I am currently using OS X El Capitan 10.11.*.

Let’s now test the FTP server on Mac OS X with the following steps:

  • Launch the
  • Type the following command to start the FTP server.
sudo -s launchctl load -w /System/Library/LaunchDaemons/ftp.plist
  • Connect to the FTP server by running ftp localhost command.
  • We’ll be asked to enter the username and password.
$ ftp localhost
Trying ::1...
Connected to localhost.
220 ::1 FTP server (tnftpd 20100324+GSSAPI) ready.
Name (localhost:wsaryada): wsaryada
331 User wsaryada accepted, provide password.
230 User wsaryada logged in.
Remote system type is UNIX.
Using binary mode to transfer files.
  • If we see the messages above and the ftp> prompt means that the FTP server works and ready to accept our command.
  • We can also try to access the FTP server using a browser. In the URL box type ftp://localhost to connect. We need to supply username and password to login.
  • To exit or close the connection to FTP server we can run the exit command.
  • Finally, to shutdown the FTP server we run:
sudo -s launchctl unload -w /System/Library/LaunchDaemons/ftp.plist

After the FTP server ready, I can now continue to create some test program to access the FTP server. There are already some examples you can find in the Apache Commons Net category that use the FTPClient library to access FTP server.

How to use Google Maven Central mirror?

The following configuration will use Google’s mirror of the Maven Central repository. Alter your ${M2_HOME}/conf/settings.xml or ${user.home}/.m2/settings.xml to add the mirror as seen in the following configuration file.

<?xml version="1.0" encoding="UTF-8"?>
            <name>Google Maven Central</name>