Step 1: Copy and paste the following snippet in your pom.xml
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<finalName>uber-${project.groupId}-${project.version}</finalName>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Step 2: Run mvn package
If everything is ok, you will see the shaded jar built in the target directory.
Step 3: Run an application using the target jar
java -cp uber-your-jar-file-1.0-SNAPSHOT.jar packagenam.classname [argument1 argument2 ...]