-2
reifnsk/minimap/ReiMinimap.java:68: error: '.' expected
import ro;
         ^
reifnsk/minimap/ReiMinimap.java:68: error: ';' expected
import ro;
          ^
reifnsk/minimap/ReiMinimap.java:69: error: class, interface, or enum expected
import sb;
       ^

I get one of these for most of my import statements, yet its all syntactically good.

Full error: http://bit.ly/1eZ5l0h Files snapshot: http://bit.ly/1eSXMdE File is more or less closed source, but most of the problems are just with import statements and switch statements.

G.S
  • 10,413
  • 7
  • 36
  • 52
DirkyJerky
  • 1,130
  • 5
  • 10
  • what are the packages you are trying to import – Jijo Jan 18 '14 at 08:17
  • 1
    We don't need the full error, and the files snapshot doesn't have useful information. Can you show the code in the class where this appears (from start of file up till `class ClassName`) – Justin Jan 18 '14 at 08:24
  • 2
    Be aware that you can have a line of code which is syntactically correct when used in the correct situation, which, when used in an incorrect situation is still bound to give you compile errors. There is much more than syntax to processing a program. – Bill Woodger Jan 18 '14 at 08:27
  • I disagree with the closing reason. What does it mean that the problem can't be reproduced? It is perfectly reproducible: put some classes into the default package, then try to import them from a class in a named package. – Malcolm Jan 18 '14 at 21:07
  • Oh back when I was a derp lol – DirkyJerky May 15 '14 at 15:46

3 Answers3

1

You are trying to import classes in the default package from a class in a named package. This will not work (at least without reflection). In order to use them, imported classes have to be placed in a named package or the class itself should be placed into the default package.

See the answer about such imports for more information.

Community
  • 1
  • 1
Malcolm
  • 41,014
  • 11
  • 68
  • 91
  • Wow, nice catch. I would never have thought of that; I never use the default package. – Justin Jan 18 '14 at 08:27
  • @Quincunx I figured that the classes are in the default package because of the naming scheme. It instantly reminds me of some obfuscation, which usually places most of the classes in the default package. The screenshot revealed that my assumption was correct. – Malcolm Jan 18 '14 at 08:29
  • I removed the package statement and moved it into the root folder of the project, yet it still doesn't want to work – DirkyJerky Jan 18 '14 at 08:47
  • @user3209348 If the file is now in the default package, you won't need the imports anymore, so just delete them as well. – Malcolm Jan 18 '14 at 09:05
0

The package statement must be first in the file, before anything, even imports.

Vivek Vermani
  • 1,934
  • 18
  • 45
0

See How to import.

Notice the example for the Fully Qualified Name:

Here is the fully qualified name for the Rectangle class declared in the graphics package in the previous example.

graphics.Rectangle

The first part, graphics, is the name of the package. The second part, Rectangle is the name of the class.

You cannot import a class that is in the same package as you. There is no reason to; you can already access it. If it is in a different package, your imports need to be changed to something like this:

import myPackage.ro;

If you know you want to use every class in a package, use a * import:

import myPackage.*;
Community
  • 1
  • 1
Justin
  • 24,288
  • 12
  • 92
  • 142