How is the java project separation?

4

Well, I come from .NET and there we have projects that we can divide into class library and web project

I have my project just for my models Another only utils project and my web-only project

In Java how is this separation made? I tried looking for some opensource java web project to see what the project structure is like

Can anyone explain me and if possible tell me a medium / large opensource project in java web (regardless of framework)

    
asked by anonymous 03.04.2014 / 14:05

2 answers

4

One thing is the division into projects done by IDEs such as Eclipse and Netbeans and another thing is the division of Java into libraries.

A Java program dynamically loads classes and resources that are available in classpath , which can be set as a parameter and consists of a list of directories and Jar files. Jar is basically a zip with compiled classes inside. So basically you can plug any dependency putting classes or jars into some directory included in classpath .

As for the development organization, you can usually create projects of various types in IDEs: libraries and desktop (jar), web (war), enterprise with EJB (ear) programs. To define which projects depend on which, each IDE has its mechanisms, but note that this is just a logical configuration for the compilation, because as already described above, in practice, all classes see all.

Update

As mentioned in the comments, there are build tools like Maven that allow you to configure the different projects, their dependencies, the artifacts generated, the whole generation cycle.

It is a more generic and agnostic way of organizing projects. I strongly recommend it because it also facilitates integration into Continuous Integration tools, static code analysis, code generators, etc.

However, this is still not something intrinsic to Java, but a logical organization of projects.

    
03.04.2014 / 20:06
2

You can separate your project into modules.

In this post, Eder Magalhães shows how to do this using Maven.

link

    
03.04.2014 / 15:34