Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to build java project using Maven?

I am using maven version 3.0.4.I am beginner in maven.I created a Hello world Java project using eclipse.

Now using maven I want to make a executable jar of it and run it.I am not getting how to do. I also googled for it but what I got is how to create a java project not how to build an existing a java project.

Help me out.

like image 414
Sanjay Jain Avatar asked Dec 29 '25 20:12

Sanjay Jain


2 Answers

Download the Maven eclipse Sonatype plugin, and create a Maven project from there.

Use the default Java project archetype usually provided in the list of available archetypes. Upon project creation you will be given a pom.xml.

With the Maven Eclipse plugin, you can build from Eclipse IDE, again the process is simple through build configuration. You will be able to see Maven build configs from there, the build command for Java project should be clean build. (Off my mind) by default, the build e.g. a JAR would be placed in the target folder after successful build.

For existing projects that need to be converted to Maven, you will have to hand create a pom.xml descriptor if you are not using the plugin.

like image 145
Oh Chin Boon Avatar answered Dec 31 '25 13:12

Oh Chin Boon


One way is to tweak the jar plugin:

http://maven.apache.org/shared/maven-archiver/examples/classpath.html

like image 44
Puce Avatar answered Dec 31 '25 11:12

Puce



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!