Skip to content
← Back to Community
Changing Main Method Class Name
Profile icon
ThomasGrossi

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.

Voters
Profile icon
CathalODonnell
Profile icon
EmmaChavez
Profile icon
cpersiko
Profile icon
skacprowicz
Profile icon
Deathcaster
Profile icon
RaniNovariany
Profile icon
MichaelPartrid1
Profile icon
geoffgeoff2
Profile icon
ThomasGrossi
Comments
hotnewtop
Profile icon
SixBeeps

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 Main.java file for the entire year.

public class Main { public static void main(String[] args) { ClassName.main(args); } }

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

Profile icon
broache

I would also like to have the ability to rename Main.
I did try deleting the contents of Main.java, 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.

Profile icon
MichaelPartrid1

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

Profile icon
DanLam13

You can use the mv command in the terminal mv Main.java Pizza.java, Will rename Main.java to Pizza.java.

Profile icon
MrForhan

@DanLam13 When you change the name of main repl.it 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.

Profile icon
[deleted]

@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 NewClassName.java and then afterwards, it ran perfectly! Thanks again.