I could not understand much from the answer above. I think Maven looks complicated. In any case, I realized if you do this, then your problem will be solved.
First, in the pom.xml file, add this plugin to the build section , as shown below.
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
I think jar-with-dependencies does the trick
Now follow this sequence of commands from your root directory (where pom.xml exists)
mvn compile
mvn package
mvn install assembly:assembly
I donβt know if the mvn package is required or not, but the third important one. Now, if you see your goal / you will see a jar with addiction.
How to start
java -cp target/Your-Jar-1.0-SNAPSHOT-jar-with-dependencies.jar com.mycode.myapp
com.mycode.myapp...
( : maven, )