0

I created a maven project using the maven-archetype-quickstart and can run both maven clean and maven install succesfully.

However, when running the maven install the "Hello world" line is not printed out. It builds succesfully and does the tests and exports the jar file.

But how to actually run the project in Eclipse itself?

Clarification. I want it to run the main method from the main class. Should I just choose run as java application?

  • Possible duplicate of [How to run maven project in eclipse](https://stackoverflow.com/questions/23810834/how-to-run-maven-project-in-eclipse) – Identity1 May 21 '19 at 08:32
  • @Identity1 Ad far as I can see that question is for building not for executing the projects main class. – Svajunas Kavaliauskas May 21 '19 at 09:11
  • 1
    Right-click the class/file that contains the main method and choose _Run As > Java Application_. Or open the file that contains the main method and click the run button in the main toolbar. – howlger May 21 '19 at 09:18
  • @howlger So the maven clean install is just to generate and export the jar file? Since I could be running the application without those commands. – Svajunas Kavaliauskas May 21 '19 at 09:21
  • Maven is just a build tool. Not more nor less. Move your mouspointer over the tag 'maven' and read the description. – Reporter May 21 '19 at 09:37
  • 1
    @SvajunasKavaliauskas Yes, the main purpose of Maven is to build the Java application (e.g. creation of the JAR). IMHO the main advantage of Maven is that Maven automatically downloads the required JARs (specified as dependencies in the `pom.xml` file) which will be automatically added to the classpath. Before there was Maven, Ant was mainly used, where you had to take care of the dependencies yourself (downloading the JARs, etc.). Maven can also be used to run an application (e.g. after building it or via a separate goal), but this is not common. – howlger May 21 '19 at 10:53
  • @howlger I see, so If I want to run the project inside Eclipse I should just run it as a Java Application otherwise(not from Eclipse) use the built jar file? – Svajunas Kavaliauskas May 21 '19 at 12:32
  • 1
    @SvajunasKavaliauskas Yes, this combines the advantages of the fast incremental compiling on save to test/debug by Eclipse and the slow non-incremental building of a JAR to ship by Maven. – howlger May 21 '19 at 14:06

1 Answers1

0

Right click on the project -> goto Maven -> update project