Another option is any classless java file is just a class with the same name as the file implementing Runnable.
E.g. Foo.java
println("foo")
Becomes: class Foo implements Runnable {
void run() {
System.out.println("foo");
}
}
Then running java Foo.java instead just stubs a main() that looks like: class Main {
void main() {
new Foo().run();
}
}