简体   繁体   中英

Unable to create packages in eclipse 3.7 and 4.2

I have two versions of eclipse and am facing the same problem in both of them. In the src folder whenever I try to create a package as abc.xyz it takes it creates a folder structure directly under the project directory rather than source directory. So finally it looks like this:

MyProject
|--abc
   |--xyz
|--src
|--other folders

I check property for abc and xyz and they are showing as folders. Even if I try to create a class inside xyz it will show up at the top level as

MyProject
|--MyClass.java
|--abc
   |--xyz
|--src
|--other folders

Additionally MyClass.java will have no package declaration. I also checked that in property window abc is listed as a folder.

Any help appreciated.

Make sure that you are in package explorer view in eclipse. Click on src folder -> build path -> Use as source folder. To avoid this step, use Java Project as a wizard when creating new project in eclipse (Don't use plain project).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM