Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

difference between building project using maven and eclipse export as Jar [closed]

This sounds like a dumb question but i am really confused with this. I never used maven but i know that it is used to build projects.

So, I have a question : why there is a need of building project using Maven when we can build project in Eclipse (without Maven). Just by exporting the eclipse project as JAR and include required Libraries and all.

suppose, I download any project from github. Now I can import that project in eclipse and export it as JAR and use it functionality. So why all suggest to use MAVEN to build project and generate binaries and use it.

like image 644
pradeep Avatar asked Jan 18 '13 09:01

pradeep


People also ask

What is the difference between Maven and normal project?

In Normal Project, if you want to work on any third party / API applications then you have to associate those jar files and associate/configure those jar files to your project manually, whereas in Maven project provide the third party/API applications dependency in POM file and then click on Maven install then ...

How to export Java project as Runnable JAR?

To export your project, right-click it and select Export. Select Java > Runnable JAR file as the export destination and click Next. On the next page, specify the name and path of the JAR file to create and select the Launch configuration that includes the project name and the name of the test class.


3 Answers

Because you will soon want to build your project automatically, using automated tools and there will be no Eclipse to help you.

Possible stuff you will need soon:

  • build your project on every commit to your repository
  • build your project on a single click somewhere in a continuous integration tool UI
  • your users may not know or care about Eclipse, but they know how to use an UI for issuing a build
like image 169
Dan D. Avatar answered Nov 03 '22 01:11

Dan D.


Assume a simple real time scenario

Development Environment -> Production Environment (leave testing now)

In dev environment, you will have all dev friendly tools to cut short your effort in writing and spend more time in working on the logic.

Once you are done with you part, you will check it into a version control.

This should move to production now. You will check out the latest version from version control into production

Now , you cant have eclipse here too! As you are not going to develop anything. In this, case, a simple pom.xml will be used all the time and the tool called Maven

Not all the time, the developer is going to prepare the binaries. So, assume some one who is not a developer is deploying ur app. Instead of asking him to open eclipse and say export blah blah blah, You can just say, run this command/batch file. That batch file will obviously contain the maven commands (mvn compile, mvn package) etc.

Finally Eclipse is to cut short development time for developers, because, u may end up running maven again and again, due to simple typo-s which can be cut short by eclipse. In production, its one time, run a batch file. Your app is deployed

like image 25
madhairsilence Avatar answered Nov 03 '22 02:11

madhairsilence


First of all, not everybody uses Eclipse (even in the same team), and different IDEs could produce slightly different artifacts (JAR files).

One advantage of Maven is that it does not only build projects:

  • it prones convention over configuration, and suggests a "standard" layout for projects
  • it allows gathering all the dependencies needed in your project, using specific versions (as opposed to having something like "lib/log4j.jar", no version is specified)
  • it allows making lots of different artifacts: JARs containing compiled code or source code, javadoc, WARs, etc.
  • it can be run outside of your IDE, very often on a continuous integration server

I would recommend using Maven even for small projects :)

like image 34
Bastien Jansen Avatar answered Nov 03 '22 02:11

Bastien Jansen