Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Sarah Raf
Ranch Hand
Posts: 35
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Brian Babbage
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 35
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic