0

I am trying to learn maven. So here is what I did.

1) Open eclipse.
2) New Project
3) create a package org.bar.foo;
4) Say thats all in my project and it has 3 files.. foo.java, bar.java and foobar.java

Now, when I look at my directory structure... it looks like

-src--org--bar--foo --all the files are here

Now.. on the top level next to src. I add a pom file..

I do mvn clean package.. Test passes..

But when I try to execute the jar, I get an error(class not found).

Turns out maven likes the directory structure to be

src--main--java--org--bar--foo.. and so on..

But now.. eclipse complains. change the package name from

org.bar.foo to main.java.org.bar.foo

I am trying to follow this example https://github.com/xamry/hadoop-examples

1
  • 1
    Maybe Eclipse can directly create a maven project like Netbeans. Look at New Project dialogs.
    – JulianG
    Commented Oct 11, 2013 at 8:08

1 Answer 1

1

if you right click on eclipse top project, you can convert it to maven project, which I recommend.

enter image description here

Another way to do is to create a scratch project with mvn archetype:generate.

2
  • I dont see "convert to maven project" option.. is that a plugin i need to download?
    – frazman
    Commented Oct 11, 2013 at 8:09
  • ofc, you need to install a plugin for eclipse to work with maven project, eclipse does not come with it.
    – RamonBoza
    Commented Oct 11, 2013 at 8:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.