Adding a Maven project to Eclipse compiled project

I am trying to add java code from a Maven project (called docx4java) which I checked out from svn to an existing Eclipse project (called DocumentManager). I have tried the normal way, that I thought would work, i.e.:

Right Click on eclipse project>Properties>Java Build Paths> Projects > Add (here I add the Maven project) and >Libraries (here I specify Native Library location e.g. docx4/trunk/docx4/src/) but I still can't get the 'Maven' classes to be recognised in eclipse. I get the message

import cannot be resolved

I have tried adding a test project that was compiled in Eclipse and that works fine, Eclipse seems to recognise it i.e. import works fine.

How can I get the code from the Maven project docx4java to work in the Eclipse compiled project DocumentManager?


You can generate eclipse poject files (which you can just import into your Workspace) using the maven eclipse plugin

Take a look at these ecplise plugins for a more direct integration of maven into eclipse

You should create a eclipse project for docx4java as @Attila has commented. Once that is done, you should have two projects on your workspace: docx4java and DocumentManager. At this point, what you are doing now (adding a project reference to the Java Build Paths) should work.

It seems that the source path is not configured correctly, this is why the compiler cannot find your "Maven classes".

Maven has a different directory structure and you have to tell Eclipse where to find your sources.

For a "vanilla" eclipse project, remove the standard eclipse build path src and add the maven source path src/main/java (or whereever you added the code), the compiler should correctly pick up your sources.

Note that you still have to add all jars mentioned in the dependencies section of the maven pom.xml file. Otherwise it won't compile, even if it finds your added java classes.

(Addendum: I would recommend to use maven in your existing project as well.)

Need Your Help

Does InnoDB have static tables?

mysql char innodb varchar database-optimization

I was reading MySQL documentation and I was wondering whether MyISAM's "static" table format also applies on InnoDB or not? Do I gain performance, if I use CHAR instead of VARCHAR when the real len...

WCF Service Method Overloading issue - Help needed

c# wcf .net-3.5 .net-framework-version

I've a WCF web service method (over 3.5 NET Framework) which needs to be refactored to use optional input parameters. Mi investigation concluded optional parameteres as a concept is being introduce...