INSTACK 360

Java Environment Setup & Hello World

A comprehensive guide to setting up the Java Development Kit (JDK) and writing your very first Java program.

Beginner 5 min read

Overview of Java

Java is a high-level, class-based, object-oriented programming language designed to have as few implementation dependencies as possible. The mantra of Java is 'Write Once, Run Anywhere' (WORA).

Setting Up the Environment

To develop Java applications, you need the Java Development Kit (JDK). Follow these steps:

  1. Go to the official Oracle website or adoptium.net to download the JDK.
  2. Install the JDK on your system.
  3. Set the JAVA_HOME environment variable pointing to your JDK installation directory.
  4. Add the JDK bin directory to your system's PATH variable.

Your First Java Program

Every Java application begins with a class name, and that class must match the filename.

public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}

Understanding the Code

  • public: An access modifier meaning this class is accessible everywhere.
  • class: Keyword used to declare a class.
  • static: Means the method belongs to the class, not an instance.
  • void: The return type; it returns nothing.
  • main: The entry point of any Java program.
  • String[] args: Command-line arguments passed as an array of Strings.