This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Java in General and the fly likes import static buggin me?! Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "import static buggin me?!" Watch "import static buggin me?!" New topic
Author

import static buggin me?!

John Blanco
Greenhorn

Joined: Jan 13, 2005
Posts: 20
I've migrated my code over to Java 5 (installed and recompiled ;-)), but Java just doesn't like my import static call:

compile-junit:
[javac] Compiling 1 source file to C:\Avatara\avatara-shared\build-junit
[javac] C:\Avatara\avatara-shared\junit\riv\avatara\chess\ChessBoardBasicTes
t.java:17: cannot find symbol
[javac] symbol : class chess
[javac] location: package riv.avatara
[javac] import static riv.avatara.chess.*;
[javac] ^
[javac] 1 error

riv.avatara.chess is a package name, but it stops and calls chess the class? The regular import works, so my classpath is just fine:

package riv.avatara.chess;

import static riv.avatara.chess.*;
import riv.avatara.chess.*;

Any ideas?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24081
    
  15

Hi,

Welcome to JavaRanch!

The argument to "import static" is different from the argument to "import". For "import", the wildcard '*' is a standin for all the classes in a package. For "import static", on the other hand, '*' is a standin for all the accessible static members of that class.

There's no way to say "import all the static members of all the classes in this package", which is perhaps what you're trying to say -- is that what you're after?


[Jess in Action][AskingGoodQuestions]
John Blanco
Greenhorn

Joined: Jan 13, 2005
Posts: 20
Well I'll be damned. :-) You answered the Q without really knowing it. I didn't get the memo that the * no longer referred to classes. :-) I'm all patched up and working, thanks!

import static riv.avatara.chess.ChessBoard.*;
import static riv.avatara.chess.ChessBoardStatus.*;
import riv.avatara.chess.*;

Originally posted by Ernest Friedman-Hill:
Hi,

Welcome to JavaRanch!

The argument to "import static" is different from the argument to "import". For "import", the wildcard '*' is a standin for all the classes in a package. For "import static", on the other hand, '*' is a standin for all the accessible static members of that class.

There's no way to say "import all the static members of all the classes in this package", which is perhaps what you're trying to say -- is that what you're after?
 
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: import static buggin me?!
 
Similar Threads
errors generated when running Ant build file in Eclipse
Unsupported major.minor version 49.0
error: package junit.framework does not exist
@WebMethod not found
package junit.framework does not exist