Maven: executing JAR created with Maven

In this tutorial we will learn how to create an executable jar with Maven and run it from command line.


Let's add a maven-jar-plugin to your pom, make sure you specify your main class as such:

<mainClass>exec.MyApp</mainClass>





Run Maven:

uki@ JavaFxSceneSwitch $ mvn clean install[INFO] Scanning for projects...[INFO]                                                                         [INFO] ------------------------------------------------------------------------[INFO] Building JavaFxSceneSwitch 1.0-SNAPSHOT[INFO] ------------------------------------------------------------------------...[INFO] Installing .. to /Users/uki/.m2/repository/edu/clcillinois/cit137/JavaFxSceneSwitch/1.0-SNAPSHOT/JavaFxSceneSwitch-1.0-SNAPSHOT.jar[INFO] Installing ...[INFO] ------------------------------------------------------------------------[INFO] BUILD SUCCESS[INFO] ------------------------------------------------------------------------[INFO] Total time: 1.822 s[INFO] Finished at: 2015-04-21T14:57:43-05:00[INFO] Final Memory: 15M/91M[INFO] ------------------------------------------------------------------------



Run the app from the ROOT of your project:


uki@ UKI_LUCAS $ java -jar  /Users/uki/.m2/repository/edu/clcillinois/cit137/JavaFxSceneSwitch/1.0-SNAPSHOT/JavaFxSceneSwitch-1.0-SNAPSHOT.jar



The JavaFX app should start, if you start it from other folder, observe how the Image path behaves.



As an Amazon Associate I earn from qualifying purchases.

My favorite quotations..


“A man should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly. Specialization is for insects.”  by Robert A. Heinlein

"We are but habits and memories we chose to carry along." ~ Uki D. Lucas


Popular Recent Articles