aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes how to create a jar file for an eclipse project using maven Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "how to create a jar file for an eclipse project using maven" Watch "how to create a jar file for an eclipse project using maven" New topic
Author

how to create a jar file for an eclipse project using maven

Sarah Raf
Ranch Hand

Joined: May 08, 2011
Posts: 35

Hi All,
I need to create a JAR file of my Java application that I have been running using eclipse. My application includes various libraries such as JOGL. jar, gluegen-rt.jar and more importantly embedded Java DB.
I want to know how I can create a JAR file for my application, using Maven, in eclipse? I did look at this link http://www.sonatype.com/books/m2eclipse-book/reference/ and http://maven.apache.org/plugins/maven-eclipse-plugin/usage.html , but nowhere has it been mentioned about how to create use an exixting Java application and include its dependencies for creating a JAR file using Maven.

Can anyone please suggest me how I can proceed? Thanks in advance....

Regards,
Sarah
Brian Babbage
Greenhorn

Joined: Aug 24, 2011
Posts: 8
I'm not sure I understand where you're having a hard time.
My suggestion would be to add a pom.xml and refactor your directory structure if needed to maven standards then build it.
Adding libraries is just a matter of resource tags in the pom.



For all things there is a first time
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5842
    
    7

You need to start with a new project that is a Maven Project and move all of your code over to that project. And add you dependencies to the pom.xml. Once you have that done, look at the Maven Assembly Plugin documentation (http://maven.apache.org/plugins/maven-assembly-plugin/), specifically the assembly:single goal. That plugin will let you package everything into a single JAR file.


JBoss In Action
Brian Babbage
Greenhorn

Joined: Aug 24, 2011
Posts: 8
Peter Johnson wrote:You need to start with a new project that is a Maven Project and move all of your code over to that project. And add you dependencies to the pom.xml. Once you have that done, look at the Maven Assembly Plugin documentation (http://maven.apache.org/plugins/maven-assembly-plugin/), specifically the assembly:single goal. That plugin will let you package everything into a single JAR file.


If you're using an IDE like eclipse you don't have to recreate the wheel. Make sure you have an eclipse m2 plugin and you can enable maven dependencies. Your classpath will change and you may have to adjust your buildpath dependencies etc. but you don't need to recreate everything which can be especially difficult if you're using subversion.

Then creating your pom (with all the gidgets and gadgets you need) should not be to terribly difficult.
Sarah Raf
Ranch Hand

Joined: May 08, 2011
Posts: 35

Thank you all for the help
At the moment I am not using Maven. But the links and suggestions did help me a lot to learn about Maven. Thanks a lot once again

Regards,
Sarah
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to create a jar file for an eclipse project using maven