Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is my Eclipse Java package being treated as a folder?

Tags:

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

like image 560
Gopal Avatar asked Feb 25 '11 12:02

Gopal


People also ask

Is a Java package just a folder?

A Java package is like a directory in a file system. In fact, on the disk a package is a directory. All Java source and class files of classes belonging to the same package are located in the same directory. Java packages can contain subpackages.

How do I fix package explorer in Eclipse?

You could try holding down Ctrl + F7 to see a list of all views, then up/down arrow to the View. If Package Explorer is in the list it has been minimised or something. If you select it and still can't see it, try Window → Reset Perspective... to restore all views to their defaults.

What is the difference between source folder and folder in Eclipse?

A source folder is marked by Eclipse as containing java sources. Then, when you compile your project Eclipse will look for your source code into all your source folders. You can make any folder become a source folder adding it to the java build path.


2 Answers

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

like image 143
adarshr Avatar answered Sep 29 '22 10:09

adarshr


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.

like image 31
marcelocra Avatar answered Sep 29 '22 10:09

marcelocra