3

As stated in the documentation about facets in general:

Project facets in Eclipse define characteristics and requirements for Java EE projects and are used as part of the runtime configuration

And the Java facet itselt in the project settings shows a description:

Adds support for writing applications using Java programming language.

All this is very general information and I cannot imagine what this facet can do for me. There are already at least two projet settings regarding java:

  • Java build path / Libraries / JRE System Library which is the default runtime, when I execute a class (test or main) from that project.
  • Java compiler which specifies (source and target) java compliance version and can optionally reference version of java from build path above.

As I see, the only result of java facet are version mismatch errors, if I set incorrect version.

I am using STS-3.6.3 and the projects are simple maven jar projects that are referenced by a maven war project. I run and debug the war project inside Tomcat from eclipse, so some of the code changes are hot redeployed (I thing, facets have no impact on this).

So, why should I keep the java facet instead of simply turning it off?

Community
  • 1
  • 1
vnov
  • 335
  • 1
  • 10

1 Answers1

1

Facets automate some parts of project configuration and deployment.
For example inform you when servlet is not added to web.xml in dynamic web project. Stuff like that.
When you add JPA facet, eclipse will create persistence.xml and will keep notifying when you create entity class but don't configure it in persistence file.
There's lots more, adding facets to projects also reconfigures how your project structure looks in eclipse.

Basically they do exactly as you quoted: "

Adds support for writing applications using Java programming language.

Every facet add something new so if you want more specific answer you have to answer question about specific facet. If you don't know what they can do for you - turn them off. You can always add them when you learn more.

Real life example:
Adding JPA facet messed up my project using ObjectDB by creating persistence file, which, turned out, I didn't even need.

zubergu
  • 3,646
  • 3
  • 25
  • 38
  • I think, with the first two sentences I started to understand and tested new simple Java project. It had 4 Java options (_Java build path_, _Java code style_ etc...) and **.project** file had only `javanature`. After that I turned on facets including **java facet** - nothing changed except new `facet.core.nature` inside **.project**. Then I removed **java facet** alone and Java options were gone. It looks like if facets are in charge of the project, than java facet must stay. If I don´t need other facet than java, than facet nature can be dropped? – vnov Dec 23 '15 at 10:19
  • You don't need facets at all. Facets are like project **additional** features, but if you configure your project with providing runtime environment and compiler you're good to go. You're overthinking facets. Drop them all,learn how to create your project from scratch manually. – zubergu Dec 23 '15 at 10:37
  • After all, it seems that I cannot drop facets. When I do that, my war projet (**J2EE Web module** in **Servers** view) does not reference the jar project (**J2EE utility jar** in **Servers**) anymore. And the server does not start, bacause of that. The key is probably the **Utility module facet** that is on (for the jar project) and cannot be turned off. And this facet requires **Java facet** in turn, so everything should probably stay. – vnov Dec 29 '15 at 09:56