C Hsu
C Hsu

Reputation: 51

Creating a new class under default package

New to Java and Eclipse. So I've created a project, and I have the (default package). Underneath I created a class. It looks fine. Then I go ahead a created another class, and I want it to be in the default package, too, but in the Project Explorer the .java file shows up under both (default package) and the /src folder. Is it supposed to be like this? What's the explanation of this. I can't seem to find something 'bout this because I guess it's a weird question.

A small illustration:

folder
  src
    (default pacakge)
      file2.java
      file1.java
    file2.java
  JRE System Library

If I delete file2, it disappears from both locations. Just want to know why the pathing happens like this, and what makes file1 different that it doesn't show under /src.

An extra note, I'd like to use the default package because I will be using a compiled bycote file that doesn't have any package specified, so I need to leave it as default.

Upvotes: 4

Views: 2283

Answers (1)

Jonah Graham
Jonah Graham

Reputation: 7970

Congrats

I think you have found a bug. I can replicate what you see. This only happens in the Project Explorer which is not the "normal" view that is used in the Java perspective. The default view is Package Explorer.

Here is a screenshot with both of them reproducing your case (With Eclipse Mars.1):

explorers

Workaround

Press Refresh (F5) or use the Package Explorer.

Why does it happen?

My guess is that not many people are using the default package, and even fewer using it with the Project Explorer. I'll file a bug report. There is already a report, Bug 418344.

Upvotes: 4

Related Questions