Ask coding questions

← Back to all posts
Changing Main Method Class Name
ThomasGrossi (6)

Is there a reason we can't change the main method class name? I really want to use this for my classroom but I am unable to teach them proper class naming scheme until we get to the AP Level where they start creating classes. I feel like this shouldn't be so hard on the back end... A simple, "Not going to happen" will suffice.

SixBeeps (5629)

Are you talking about the method itself or the class name? If you mean the method, then that would go against the language's standards for how a program should be structured. If you mean the entry-point class, then that's something that could possibly be done. I'm currently in AP Computer Science A using Java, and I've just dealt with using this as my file for the entire year.

If you feel like this is an extremely important feature, try giving it a stab over on the Feedback page.

broache (1)

I would also like to have the ability to rename Main.
I did try deleting the contents of, then creating my own .java file with a main() method and a class/file name of my choosing, and it appears to work. Still, I don't really want to put students through that.

MichaelPartrid1 (1)

Yes... allow class names other than "Main"

DanLam13 (0)

You can use the mv command in the terminal mv, Will rename to

MrForhan (1)

@DanLam13 When you change the name of main breaks. It still looks for the Main class. Shame, because this is otherwise a good learning tool. Fortunately there are other web based IDE's that don't have this limitation.


@DanLam13 thank you! This actually worked for me. I tried to run the code again but received an error message, and remembered that I had to run javac and then afterwards, it ran perfectly! Thanks again.