Why is my Eclipse Java package being treated as a

2019-04-03 23:41发布

My Eclipse Java package is treated as a folder; can anyone suggest what's wrong?

12条回答
萌系小妹纸
2楼-- · 2019-04-04 00:25

First, ensure that you're in the "Package Explorer" view of the Java Perspective.

Secondly, it needs to be made a Source Folder.

If you're in the Java Project, right click on the folder and select "Build Path" > "Use as Source Folder"

Something like what is shown here:

Observe that I am in Java perspective and see how the style of the folders "source" and "src" are different in appearance.

Eclipse Screenshot

查看更多
家丑人穷心不美
3楼-- · 2019-04-04 00:29

This kind of issue occur due to missing of java and test folder in the web application

solution is :

Right click on the project folder -> properties -> java build path -> order and export and select the java and test folder and add or apply -> ok

then you should able to add the package in the java folder

查看更多
ゆ 、 Hurt°
4楼-- · 2019-04-04 00:30

Well, I actually think you might don't even need the answer anymore (almost two years later) but I will share anyway to document (just found a solution that others could use).

The problem: while searching some packages I accidentally clicked "Add to build path" in a package and after I ctrl+z, the package had became a folder.

The solution I found was on the .classpath. There was a line there with the name of the package I had just added to the build path (even after the Ctrl+Z). Delete that line and after refreshing the project your whole src folder will be turned into a normal folder.

Then right click your src, following this path: src > Build Path > Use as Source Folder.

This solved the problem, I just tested the result. Hope it helps.

查看更多
啃猪蹄的小仙女
5楼-- · 2019-04-04 00:30

Just switch to java perspective, in the ide (top right corner-> java...)

查看更多
时光不老,我们不散
6楼-- · 2019-04-04 00:34

I tried mvn eclipse:eclipse and it worked. One to watch out is the .project file.

查看更多
Melony?
7楼-- · 2019-04-04 00:35

Creating a package makes an older one instead.

I had the same problem, and I was not able to solve it. But I suggest this, as a possibility. After copying and moving classes between packages, any file, it could be that the classpath has different information and that it hasn't been updated.

After having read some comments above, I now am only using source folders instead the standard source Folder "src". Inserting packages in any new source folder always runs.

查看更多
登录 后发表回答