Search code examples
javaeclipsepackage-explorer

Packages not listed while creating a class in Eclipse


I am facing a couple of issues in Eclipse and I feel they are related.

  1. I cannot see the structure of packages in style package.subpackage1.subpackage2 but in the folder structure we see in windows explorer i.e.
    package
    |--- subpackage1
    |---subpackage2

  2. While I try to create a class in a package , it is added to a default package and I cannot see a package as the packages are not listed.

An illustration of the problem

I checked perspectives as well - the issue persists in Java or JavaEE perspectives. I also changed the "Package Presentation" to "Hierarchical" but it wouldn't help. I checked with Package Explorer as well as Project Explorer. I am using Photon Release (4.8.0).

I tried searching it on Google and here in StackOverflow too but found nothing relevant thus seeking help from the community.


Solution

  • You put your Java class files into the source folder src/main/resources (where in Maven by default .java files will be ignored to be compiled) instead of into the source folder src/main/java.