An exception thrown from a static intialiser may indicate a design problem. Really you shouldn't be attempting to load files into statics. Also static should not, in general, be mutable.
For instance, working back with JUnit 3.8.1 you could almost use it from an applet/WebStart, but it failed due to one static initialiser doing file access. The rest of the class involved was fitted the context fine, it's just this bit of static which did not fit the context and blew the whole framework away.
There are, some legitimate cases where an exception is thrown. If it's a case that the environment doesn't have a particular feature, say, because it's an old JDK, then you might want to substitute implementations, and there is nothing out of the ordinary. If the class really is borked, throw an unchecked exception rather than allowing a broken class to exist.
Depending on your preference and the problem at hand, there's two common ways to go around it: an explicit static initialiser and a static method. (I, and I think most people, prefer the former; I believe Josh Bloch prefers the latter.)
private static final Thing thing;
static {
try {
thing = new Thing();
} catch (CheckedThingException exc) {
throw new Error(exc);
}
}
Or
private static final Thing thing = newThing();
private static Thing newThing() {
try {
return new Thing();
} catch (CheckedThingException exc) {
throw new Error(exc);
}
}
Note: statics should be final (and generally immutable). Being final, correct single assignment is checked by your friendly compiler. Definite assignment means that it may catch broken exception handling - wrap and throw, do not print/log. Strangely, you can't user the class name to qualify the initialisation with the class name in the static initialiser (I'm sure there is a good reason for this).
Instance initialisers are similar, although you can make the constructor throw or you can put the initialiser within the constructor.