Writing First Program
Create a minimal Java application with a main method, print output, then compile and run.
Lesson Goals
Goal: write, compile, and run your first Java program.
- Create a source file and a class.
- Add the
mainmethod. - Print a short message.
- Compile with
javacand run withjava.
Class and File
Class and file
- Create a folder for your project.
- Create a file named
Main.java. - Each Java file typically defines one public class.
- The file name must match the public class name.
All lessons in this course
- Introduction to Programming
- Installing JDK & IDE
- Writing First Program