Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a src/main/java folder structure in Eclipse without Maven

How do I create the src/main/java and src/test/java in my default web application project in Eclipse without Maven? My current folder structure is

TestApp ├── JavaResources │   └── src   │       └── com.mypackage └── WebContent 
like image 970
Sandeep Rao Avatar asked Apr 07 '14 14:04

Sandeep Rao


People also ask

How can I change src main java to src in Eclipse?

To do this, right click on the src folder and select build path -> remove from build path. Once you have done this src will appear in the folder tree in its normal place, so you can create the main and java folders under it, and move the existing src/com to src/main/java/com .

What is src folder in Eclipse?

src is where Java IDEs (at least Eclipse and NetBeans) put the source files, it is pretty much standard, and the hierarchy of the folder inside it has to match your Java packages names.


1 Answers

As you've discovered, you can't have a source folder inside another source folder, so before you can create src/main/java you have to tell Eclipse not to treat src as a source folder. To do this, right click on the src folder and select build path -> remove from build path.

Once you have done this src will appear in the folder tree in its normal place, so you can create the main and java folders under it, and move the existing src/com to src/main/java/com. Finally right-click the newly-created java folder and select build path -> use as source folder.

like image 82
Ian Roberts Avatar answered Sep 23 '22 10:09

Ian Roberts