Ask coding questions

← Back to all posts
Change the Name of Main.java
skacprowicz (1)

I'm using Replit Teams for Education to make assignments for students, and evaluate them using Unit Tests. I'd like them to be able to rename the Main.java file to something more meaningful for our applications. Is this possible? The students are sometimes inexperienced, so I'd hate for them to have to go in and make changes through the command line. I'd rather it be delivered to them with the name already changed.

Comments
hotnewtop
OldWizard209 (1531)

You must be getting an error when you change the file name right?

This is because replit is configured to run a file named Main.java in the shell. So if you change the name to something else, replit can't find Main.java, so it throws an error.

To fix this, you have to create a .replit file, and put in this command:

run = "<run command here>"
language = "<repl language>" # optional

This will run the desired filename, no matter what the name is of the file. You can even attach multiple language files in one repl.

Hope I was helpful!!!

:P

skacprowicz (1)

@OldWizard209 Yes, that solution works, but I can't distribute the .replit file to my students when they fork it. Is there a way to do that?

OldWizard209 (1531)

No, when a repl is forked, all the files/contents of the file are cloned into another repl. So that way, the .replit file will be forked. You can try that by creating a .replit file and forking the repl yourself. @skacprowicz

skacprowicz (1)

@OldWizard209 Ah, ok. Yes, I just had a new student fork the assignment, and the files were distributed. I guess it didn't update for the first student, since the .replit file wasn't there when they had originally forked the assignment. Thanks all!!

codingjlu (215)

You can create a Bash repl that runs that Java file...