Skip to content
How to change the file name without error?(java)
Profile icon

(I'm a new coder so I might not know a lot.) Basically, I changed the class from "public class Main" to "public class emails". I then changed the file name to "" too, but when I ran the code, it said "unable to run, main file "" not found." It kept on saying this after everything I tried. How can I stop this?
Also, whenever I add a new file to try to start over, it just prints the code from the file no matter what I do.


You are viewing a single comment. View All
Answered by JacobMcPherson1 [earned 5 cycles]
View Answer
Profile icon

To further elaborate on what

said, the reason why this happens is because Replit maps a console command to the run button for every language. By default, this command compiles a file named and then runs it. If you rename the already-existing file that comes with the Repl, that file will no longer exist, and the command will fail. By retting the command manually in the .replit file, you are then able to map a different file name to compile and run.

This is the best option here since then you won't have to type the commands each time you want to run the program, but it's certainly not your only option. Throughout APCSA, I would create a new Java file for the runner class instead of using Main, then execute the runner's main method from the Main class' main method.

Profile icon

ok thanks