Ask coding questions

← Back to all posts
How do I fix a "Could not find or load main class Main" error?
SHANEKASNER (2)


Answered by PattanAhmed (1405) [earned 5 cycles]
View Answer
Comments
hotnewtop
PattanAhmed (1405)

@SHANEKASNER Hi,
It seems like your code that you have written should be transferred to file name called Main.java
Try!
Thanks!

Hope this helps

Coder100 (18123)

Hello, two ways:
1. Copy all your code into Main.java
2. Configure the run button:
Create a .replit file:

run="sh main.sh"

Create a main.sh file:

javac ExpressionsWithLiterals.java RectangleArea.java
java ExpressionsWithLiterals
CodeLongAndPros (1624)

Your code needs to be in Main.java