• Post Reply Bookmark Topic Watch Topic
  • New Topic

Compiler doesn't recognize java.util and java.io  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I try to compile the Sink a Dot Com game it doesn't recognise the java.io and java.util. I did not type them wrong cos the GameHelper class (Chapter 6 Head First Java) I downloaded from wickedlysmart.com. Can anyone help me on finding out the problem? Thanks.

Here is a Screenshot on what happens when i try to compile:

screenshot_03.jpg
[Thumbnail for screenshot_03.jpg]
 
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Giorgio. Welcome to the Ranch!

Looking at that error, I'm not entirely convinced the problem is that it doesn't recognise the packages. The error is pointing at the import keyword. I think you might have them in the wrong place. That's made even more likely by the line numbers: 91, 129, 130. The import statements should be at the top of the file, after the package statement but before anything else other than comments.
 
Giorgio Momigliano
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I put all the 3 classes in the same file, didn't make 3 different ones. So i copied 3 times java.util and once java.io. I found this out, so i deleted most of the copies and then compiler told me that they should be in different files.

Thanks Matthew, wouldn't have figured it out without your comment
 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.

The part about separate files: Java requires all public classes to be in a file with the same name as the class (so a class called Game is in Game.java). Non-public classes don't have the same restriction, so I'm guessing the ones you copied were probably all public.
 
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch, Giorgio.

Some tips for using the forums: Please post text, not screenshots, and please include your source code when you have a problem - that would make it much easier to help you with the problem. When you do post source code, please use code tags, so that the forum software can format your code properly.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!