aspose file tools*
The moose likes Java in General and the fly likes import static buggin me?! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
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: 24168
    
  30

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://aspose.com/file-tools
 
subject: import static buggin me?!
 
Similar Threads
@WebMethod not found
package junit.framework does not exist
Unsupported major.minor version 49.0
error: package junit.framework does not exist
errors generated when running Ant build file in Eclipse