Tag Archives: Maven

How To Install Apache Maven on CentOS/RHEL 7/6/5

Step 1 – Install Java

Click here

Step 2 – Install Apache Maven

Continue reading How To Install Apache Maven on CentOS/RHEL 7/6/5

Snippet Maven

With snippet Maven, you can free your mind

  1. Create a Jar with Dependencies using


    and you run it with


  2. Create a Jar with Dependencies using


    and you run it with


    Compile goal should be added before

    or otherwise the code on your own project is not included.

    Commonly this goal is tied to a build phase to execute automatically. This ensures the JAR is built when executing

    or performing a deployment/release.


  3. Create a Jar with Dependencies using

    You can use the dependency-plugin to generate all dependencies in a separate directory before the package phase and then include that in the classpath of the manifest:


    Alternatively use “${project.build.directory}/classes/lib” as OutputDirectory to integrate all jar-files into the main jar, but then you will need to add custom classloading code to load the jars.

  4. Delete additional directories and files using

    The Maven Clean Plugin will delete the

    directory by default. You may configure it to delete additional directories and files.


    Note: The directory in the fileset is a relative path inside a project, in other words


    is equivalent to:


  5. Set UTF-8 for project when build


  6. Compiler exclude the specified packages and their subpackages


Maven setting up the Internal Repository

Add internal repository from project

${basedir} is variable of eclipse

Local File In Project
Local Repo

Add dependency

  • When using command mvn eclipse:eclipse , maven will copy file from folder repo to folder .m2 (C:\Users\EURO\.m2\repository\com\amazon\RedshiftJDBC41\1.1.9.1009)
  • On EC2 server you must deploy your library to folder /usr/lib/jvm/jre/lib/ext/RedshiftJDBC41-1.1.9.1009.jar.

Adding external/custom jars into Maven project

I. Using system dependency

The second method is to add the required dependency with the system scope and additionally provide an absolute path to the a jar file placed somewhere on the local disc:

You must deploy your library to folder /usr/lib/jvm/jre/lib/ext/RedshiftJDBC41-1.1.2.0002.jar.

II. Installing jar into local Maven repository

  • First we need install maven on your server follow steps by step:
  1. Run the wget command from the dir you want to extract maven too.
  2. run the following to extract the tar,
  3. move maven to /usr/local/apache-maven
  4. Next add the env variables to your ~/.bashrc file
  5. Execute these commandssource ~/.bashrc

6. Verify everything is working with the following command

  • Much better solution is to add the required dependency manually to the local repository using command:

  • For example adding external jar evalpostfix-1.0.jar to the local repository could look like this:

III. Add library by manual

  • Install 7-zip on your window and open jar file, copy your library into this jar file.