0Pricing
Java Academy · Lesson

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 main method.
  • Print a short message.
  • Compile with javac and run with java.

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

  1. Introduction to Programming
  2. Installing JDK & IDE
  3. Writing First Program
← Back to Java Academy