Packages not listed while creating a class in Eclipse

210 views Asked by At

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.

2

There are 2 answers

0
howlger On BEST ANSWER

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.

0
Sarfraz Shaikh On

Problems seem to be that you do not have a source folder. Right-click on your project -> Build Path -> Configure Build Path

In Configure Build Path select Source tab. Add source folder src/main/java. Create your packages and java files in this folder