Atom Feed SITE FEED   ADD TO GOOGLE READER

Quine Programs in Java

Michael Kölling blogged about Quines - programs that print themselves. Here's my best effort in Java (prettyprinted for readability):
class A {
static {
String a="class A{static{String a=%s%s%1$s;System.out.printf(a,'%1$s',a);}}";
System.out.printf(a,'"',a);
}
}

Can you beat 122 characters?
Comining this with Daniel Gronau's enum technique, I can hit 112 characters!
After doing my best effort, I'm only 4 characters off from the optimal one here. Of course I should have thought to use ant int for the quote character!
What am I missing? Don't you need a main() method?
Not really. Static initializers run before main().
Yeah...but then it blows up and prints an error message. Feels like cheating a bit.
Yeah, it's cheating. The workaround is to call System.exit(0) at the end.