SoltanG
SoltanG

Reputation: 185

Eclipse confusing package to be a folder

I have read some questions on this around here but my tries at the answer have not yielded success. Here is the problem:

The proper package structure is com.me.a.b, but eclipse thinks 'b' is a folder. When I right click on b and go to build-source, there is an option that says "use as source folder" which then does something totally unwanted - creates a separate folder with the entire package path as a source folder, and uses a default package:

How do I solve this annoying issue?

PS: I am unable to use images which to give a better idea but being new here, there is a restriction.

Upvotes: 1

Views: 5310

Answers (3)

I just had this same problem with ONE folder between about 100 folders. The solution turned out to be righ click on the folder (in the package view), choose "Build Path", and then "Include" (Instead of 'use as a source foldre' as the OP did). After that the folder turned into a package.

Upvotes: 1

Chris
Chris

Reputation: 3529

You have project/com/me/a/b set as the source folder. Your build path looks something like this. enter image description here

You need to set project as the source folder. Your build path will look something like this afterward. enter image description here

Upvotes: 2

Svilen
Svilen

Reputation: 1447

this is very strange. packages are basically folders, so saying that you have package com.me.a with a folder in it named b is essentially the same as having package com.me.a.b. Or there is something wrong with the Eclipse's workspace metadata for this particular project? Try creating new project with such package and class in it see if it is any different?

The behavior you describe when choosing "b" as a source folder is expected: you are basically telling eclipse that this folder b is a source folder, a root folder for source java files. this is the default package, every sub-folder of this one is considered a different java package...

Upvotes: 1

Related Questions