Sign up ×

I'm learning to use Springsource Tool Suite (STS) and the Spring framework for development. I am trying out the Amazon AWS SDK for eclipse and decided to install it into STS. When I follow create a new AWS project, it puts the .java file under src instead of src/main/java and when I try to build that, it says

"There is no main" or something like that.

But, when I move the and the to src/main/java then (default package), I can run the file as a Java application.

My question is, what is the difference between src/main/java -> default package and src -> main. I've attached an image to clarify things:


share|improve this question

1 Answer 1

up vote 4 down vote accepted


Each Java project in Eclipse (and STS as well), has associated build path, where it is specified, which folders in the project contains java classes. Thus, the difference between src/ and src/main/java is that src/main/java is configured as a folder, containing java classes (or source folder in Eclipse terminology), while src/ folder just contains the source folder.

More information can be found in Eclipse Help.

I'm not sure what has caused that your Java classes end up in the wrong folder, but this means that they are not in the classpath of the project. So, when you run your application as Java application, it complains that it cannot find main() method (which is the default entry point for any Java application).

Everything comes into place, when you move your classes under the default package in src/main/java: Eclipse finds your Java classes and the main() method.

share|improve this answer
Can anyone please tell me when we create a new Maven project, src/main/java and src/test/java get created. What is the basic difference between these two.Basically while preparing webdriver automation script we add all the test cases and java files to src/test/java folder. Why we do so? –  Nilanjan Saha Sep 16 '13 at 14:18
@Nilanjan It's Maven recommendation of how you organize your project for easier management. Everything, which would be deployed in production or it will be used by other modules is usually placed in src/main/java. All the tests, which you write for this module would go in src/test/java. When Maven is compiling it separates the artifacts from the two folders and combine them only when it's necessary. For example, if you consume the module in another module, you'll get only the src/main/java. When you are running the tests, the classpath would be combined src/main/java and src/test/java. –  Danail Nachev Oct 21 '13 at 17:30

Your Answer


