- Download and install Java from here
- Download Apache Maven from here
- Follow the instructions to install Maven
- add the following lines to your .profile:
export M2_HOME=path to Maven export PATH=$PATH:$M2_HOME
- . ./.profile
- mvn –version
Create a Sample Project from the Command Line
- CD to your Development Root folder
- mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
This creates the following directory structure:
my-app +- pom.xml +- src +- main | +- java | +- com.mycompany.app | +- App.java +- test +- java +- com.mycompany.app +- AppTest.java
Build the Project
- cd my-app
- mvn package
This creates the following directory structure within my-app
my-app +- main ... +- test ... +- target +- classes | +- com.mycompany.app | +- App.class +- maven-archiver | +- pom.properties +- my-app-1.0-SNAPSHOT.jar +- surefire +- surefire-reports | +- com.mycompany.app | | +- AppTest.txt | +- TEST-com.mycompany.app | +- AppTest.xml +- test-classes +- com.mycompany.app +- AppTest.class
Run the Project
- java -cp target/my-app-1.0-SNAPSHOT.jar com.mycompany.app.App
- prints Hello World!
For more information check out Maven in 5 minutes