Java Hello World! Code Contest

An Austin area jug apparently had a contenst recently to see who could write the smallest java class that would output "Hello World!". Simple rules, has to run on JRE 1.3, whatever files are used count towards total of bytes, command line arguments passed in do NOT count towards bytes.

Sounds simple but gets tricky. I saw this as an article in JDJ, the original is here. The author does much better than I did (I tried before checking out what he did) and gets a resulting file of 70 bytes. My effort was a bloated 323 bytes. I dont know the results of the contest or any other details.

Anyway its interesting stuff and it delves into how the JVM works, etc. Check it out.

Comments

Re: Java Hello World! Code Contest

actually i got down to 309 with this.

-----------------------------------------
class h {static{System.out.print("Hello World!");}}
----------------------------------------

a friend got 134 with this (borrowing the sun class from the article).

----------------------------------------
public class h extends sun.security.util.PropertyExpander{}
----------------------------------------

compiling with -g:none and -target 1.3 helps a bit. i tried jikes and it made LARGER class files.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.