File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes the declared package com.mycompany.util does not match the expected package Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "the declared package com.mycompany.util does not match the expected package """ Watch "the declared package com.mycompany.util does not match the expected package """ New topic
Author

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

Jef Smith
Greenhorn

Joined: Jul 28, 2011
Posts: 14
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

Joined: Jul 28, 2011
Posts: 14
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
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: the declared package com.mycompany.util does not match the expected package ""
 
Similar Threads
my .war with .jars
File hierarchy vs Package hierarchy in Eclipse
Reading Chapter 10 to Grasp Chapter 1 public, protected, private mechanisms
Question about java and javac commands
Executing my .java in package