• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

"package" and "import" problem

 
Richard Jackson
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,every one
After busy with my work for two months,I reconsider some naive problems in my assignment.
I am just doing URLyBird project,some data access functions must be
created as member classes of the suncertify.db package

That is what I am not able to run the code after compiling.And the RecordNotFoundException class compiles well.
This makes me so doubted.
Code looks as follows:

When I run the code,error information occurs:

cannot access RecordNotFoundException
class file contains wrong class:suncertify.db.RecordNotFoundException
Please remove or make sure it appears in the correct subdirectory of
the classpath.

What can I do?I feel confused.
Regards,Richard
 
George Marinkovich
Ranch Hand
Posts: 619
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Richard,
The RecordNotFoundException should be in the same package as the Data class. Is this the case with your code? In other words, do you have RecordNotFoundException.java file that looks like this:

The Data.java and RecordNotFoundException.java files should be in the same directory. For example, something like this:

If both of these things are true for your code and you're still having a problem with compilation let me know.
Hope this helps,
George
 
Richard Jackson
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,George
Thanks for your reply.
I know some about the definition of "package",and I understand the structure as you said.
So I do practices again and again,finally,I found the IMPORTANT POINT.
RecordNotFoundException.java

The above class is located to the same PACKAGE.
The POINT is:

And then it compiles successfully!
Hope it helpful to other persons.
Regards,Richard
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic