maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bernd Eckenfels <>
Subject Re: maven - using multiple src directories
Date Wed, 01 Aug 2018 07:07:44 GMT

First of all the normal rule of thumb for Maven is, don’t fight it. If it uses by default
one folder for main and test code then this is a good best practice which you should not divert
from. Especially not for „multiple packages“, it is quite normal to have them all under
a single source.

If there is a good reason to isolate those packages more it might be a strong hint to use
multiple maven modules or projects.

If you chose to ignore that advice I would go with the build helper approach described on
your stackoverflow link.

BTW: in case you want to build a multi-(jigsaw)module project I think there is not a clear
definition for project layout yet, however having one module directory under main/java with
one maven module per jigsaw module is the most classical structure.


Von: angelo moreschini <>
Gesendet: Mittwoch, August 1, 2018 8:47 AM
Betreff: maven - using multiple src directories


I am new to maven.

Actually I am able to compile and run a simple java project (if all the
classes are in the same source directory).

As well this, to progress in my learning (because the java language have
the package structure to group classes inside directories) I need to be
able to write java classes also inside multiple source directories.
*Maven give me error if I write java classes in different directories.....*

*How to do because this works ??*

Looking on Internet I found this article :

there is the suggestion of modify the pom file in this way:

<sourceDirectory>src/main/java, src/interfaces,


Because I did it , maven now works (I can get the file.jar). ..

But I am not able to run the file .jar , after I got it..

*(using the command : <java -jar osmwse.jar>)*

I get the error :

*Error: Could not find or load main class*

nothing changed in the file... (only the pom file changed.).

*I think maven have to be able to mange (in a simple way) projects with
source code wrote on multiple directories...*

how to do it ???

Thank you


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message