the.wizard
the.wizard

Reputation: 1109

Why do my java files look strange in Eclipse?

I just got confused with my Eclipse project, the java code file appears strange like this: enter image description here

It should be look like this: enter image description here

Does anyone know what is the difference of those java file? And how do I resolve this problem? Thanks and regards.

Upvotes: 10

Views: 7658

Answers (5)

prat8789
prat8789

Reputation: 91

The same issue happened with me also and by looking at your the screen shot the reason must must be same. Please check your .classpath file in the root folder of your project. Since you are using a version control system, if the .classpath file is in conflicted state even though the src folder is set currently the files will be treated as non source (you cannot 'Link with Editor' or use features like F3).

Upvotes: 0

Sachin Pete
Sachin Pete

Reputation: 21

right click on project "build path" then confingur build path then to source. check that is there any source attache to it. if attahced then change to your src folder.

The same above if the attachment not shown then select folder then click on src ie source

enter image description here

Upvotes: 0

Isaac Herrera Monge
Isaac Herrera Monge

Reputation: 11

I know this is a little late, but i had the same problem and couldn't run anything, so I did some research and found the problem was as said by Sergey, I fix it by right clicking in the Project > Build Path > Configure Build Path > Source then deleting the source path and adding the new source path, the project location. Hope it works, it worked for me

Upvotes: 1

BostonBala
BostonBala

Reputation: 1

The first one is the folder view and the second one is the project view. For the first the one to look like the second one. Delete the project and make sure do not delete the content on the disk, then use import -> existing mvn project, then you will see this correctly and make sure you access the package level and not the root.

Upvotes: -1

S. Pauk
S. Pauk

Reputation: 5318

It's related to how Package Explorer is showing the project content. The second one (solid blue J icon) shows Java source code while the first one shows just a folder structure with any files in it (Java files in this case). Meaning that if you fail to see the second one then your project is in trouble since there's no source code folder configured.

You could check you project sources by right click on project > Java Build Path > Source

If you want to avoid confusion then I'd recommend to use the Navigator view over the Package Explorer view cause the former shows your folder structure as it is w/o any modifications.

Upvotes: 6

Related Questions