Observe these steps to compile and launch a Java programme:
Use a text editor or an IDE to create Java code.
The file should be saved with a.java extension (such as “MyProgram.java”).
Activate a terminal or command prompt and go to the directory where the Java file is located.
Use the javac command to compile the Java source code: javac MyProgram.java.
The creation of a bytecode file (.class) indicates that the compilation was successful.
Use the Java command: java MyProgram to run the programme.