• Post Reply Bookmark Topic Watch Topic
  • New Topic

the declared package com.mycompany.util does not match the expected package ""  RSS feed

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I added a JUnit test to my Eclipse project as follows:



I have this package statement in TestResponder.java:



The source folders on the build path are:


Eclipse is displaying the message: the declared package com.mycompany.util does not match the expected package ""

I just can't figure this one out. Eclipse thinks the package should be "", i.e. no package. I thought the package, or the expected package, was determined by the file path.

I'm sure this is a simple misunderstanding of how packages are named but I've tried everything I can think of to fix this and gotten nowhere.

Any help or advice would be appreciated.

jsmith

 
Jef Smith
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm answering my own question. Does this mean I'm getting smarter or dumber?

All I did was save the file then close it. I reopened it to try another change and the error message was gone.

So I guess the package information was correct all along. I think the root cause may have been that I added the test directory to the build path BEFORE saving the source file. After chasing this problem for an hour I'm not in the mood to experiment but I'm guessing this is a case where Eclipse could not keep up with what was being done and was displaying an error message for an older version of the source file and/or the project itself.

Thanks to all who even thought about responding to this one.

jefsmith
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!