Accepted answer

simply create a java directory under main (i.e. src/main/java) and right-click on your project and select maven > update project configuration.


error occurs when the jre system library is wrongly pointed. now go to libraries tab and change the jre system library to the correct version.


in intellij idea 13 you must first create "java" folder in main folder then --> go to "open module setting"- for this you can click on project name and press f4- , and set label of "java" folder to "source" .


here is my solution. it works without any issue.

there could be questions regarding why all this steps are required and i believe they are pretty genuine. but this is one of the ways to make your web application or any other component working on eclipse using maven from command line.

1) open a command window

2) mvn archetype:generate -dgroupid=your package -dartifactid=your project -darchetypeartifactid= your archetype. in my case "maven-archetype-webapp" -dinteractivemode=false

3) cd your project

4) mvn eclipse:eclipse -dwtpversion=2.0

5) go to file system. go to your newly created project. create folders, a) java under main
b) test under src c) java and resources under test

6) mvn eclipse:clean

7) mvn eclipse:eclipse -dwtpversion=2.0

8) import your project project in eclipse

thanks, sid


do it the other way around. first make a webapp project, then add the maven framework (in intellij - right click project and select add framework support). it will create the right folders for you.


i had the same problem even when i added jre system library to my current java version but still had same problem then i just deleted jre system library and added once again it worked for me

  • to delete jre system library right click on project ->properties ->java build path -> select jre system library -> remove

  • to add jre go to properties->java build path -> add library ->jre system library -> choose jre -> finish


just add a new folder "java" under src/main. will solve the problem. because the classpath with java folder is already available in .classpath file of created project, so adding java folder will not cause any error. see below entry in .classpath file, which allows to add java folder.

<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>


following steps work in eclipse 2020-06

  1. file->new->maven project
  2. choose "create a simple project (skip archetype selection)"
  3. choose packaging as "war" (this will create both webapp and java folders)
  4. create the project after specifying group id and artifact id
  5. update pom.xml with java and compiler versions, then right click on project, select maven->update project
  6. if the project is not faceted form (its not in faceted form if on expanding project in project explorer, it doesn't show details such as "deployment descriptor" and "jax-ws web services", this happened in one of my eclipse installation and i had no clue why), then do the following steps
    1. right click on project, go to properties, click on project facets, convert to faceted form, choose correct "dynamic web module" version, enable the checkbox and also choose correct java facet version.
    2. "further configuration available" gets displayed in that window, click on it and specify webcontent folder. (replace webcontent by src/main/webapp)
    3. if you want to run the application in servers configured in eclipse, then specify maven dependencies to be deployed in "deployment assembly". this will deploy maven "provided" dependencies also, but i think its fine for testing. for actual distribution, you can supply war file generated from maven package.


there is an option to create a source directory in eclipse. or you can go to build path under project properties, and add an existing directory as a source directory.

if you are going to use non-standard directory structure you will have to specify it in maven though


a webapp structure gets generated but with no 'java' directory under main

create src/main/java on your own.

furthermore, there seems to be no compilation of it by java. i can make stupid errors and no syntax highlighting comes up. it's like java isn't recognizing it.

after creating appropriate dir structure execute the maven command

mvn eclipse:eclipse 

then refresh the project in eclipse.



for src/main/java your project >> properties >> java build path >> source >>
search "your project src/main/java (missin)" >>>

edit > folder name >> next >> inclusion patterns: -----> add >> src/main/java ok

and if errors still don't disapear

>>>  look in target runtimes  and check your apache in checkbox


right click the maven project -> build path -> configure build path in order & export tab, you can see the message like select 'jre system library' and 'maven dependencies' checkbox click ok now you can them


this is a great article that i read when i was having trouble understanding how to build multiple projects into one using maven. specifically, this article explains how to set up a web project (war file) to consume an inner standard java project (jar file).

if you have a basic understanding of maven, skip to the sections at the end: how do i build other types of projects? how do i build more than one project at once?

if you aren't familiar with maven yet, check out:

trust me, mkyong knows what is up!


simply create new folder named java under src/main/

then right click on project and select maven->update project


anything else is likely to be down to the archetype and how you've configured your pom.xml. the directory structure you describe is identical to the one maven-archetype-webapp creates on the command line.


simply create a java directory under main (i.e. src/main/java) and right-click -> build path -> use a source folder


  1. by default, when you create a project with maven archetype "maven-archetype-webapp", it doesn't create any java and test folders.
  2. you can manually add those folders as src/main/java and src/test/java.
  3. after adding these folders, right click on your project in project explorer, go to maven>update project conf.

Related Query

More Query from same tag