Replit seems to be a bit picky about the program structure, it should look like this:
import java.util.Scanner;
class Main {
public static void main(String[] args) {
System.out.println("Hello world!");
}
}
Starting with another name than class Main will give an error.
Also see:
Java Class Methods[
^]
See this working TicTacToe example:
Invitation to collaborate on Replit[
^]