*LOOK* at the error message you are getting:
story.java:1: class, interface, or enum expected
var it = 0;
That is a JAVA error.
You can't use the keyword var
in Java. You can't use document.write