What William said. Also it would need to be an applet, derived from a specific class in the Java standard library. Applets don't start from the main method like ordinary Java code.
Viewing post in How to Create Java Applet or HTML
With... a text editor?! Look up a HTML tutorial, e.g. on MDN. But you need a web page that embeds a Java applet. Which is 1) not the same thing and 2) not necessary, because Itch supports Java applets directly. Did you look in the list of project kinds when creating a new one?
How did you circle back to making an applet anyway? We were just talking about making it downloadable because most browsers don't support Java applets anymore. And you can't get around that with tricks.
Thank you for taking your time to help me. I was hoping to use itch.io so that people who don't have Java can play my game very easily. I don't want to ask them to download Java so they can run .jar files. I also tried making it an .exe file but I kept getting messages saying that "this program may have a virus" and I do not want anyone to experience that just for trying to play my game. That is why I think that a Java applet is the best thing for me.
So do you know how to take a regular Java program using graphics, and turn that into a Java applet so that it can be uploaded to itch.io? I understand that applets are deprecated because most browsers don't support them anymore, but is there still a way to make them from a Java IDE such as Eclipse?
Once again, you don't have to ask players to download Java because most likely they have it installed already. And to be sure, you can use a utility to bundle the Java runtime with your game. Just search for one online. Spurious warnings from antivirus software are common, many developers run into that problem. And Java applets were deprecated precisely because they were terribly insecure.
No, I don't use Eclipse, but I did make a Java applet long ago, and it has to be made as an applet, which inherits from a specific class in the standard library, and draws on a canvas in the way of output. Eclipse being a big serious Java IDE probably has a project template for that kind of thing. Look for it, and/or check the Eclipse documentation.