Skip to main content

Getting Started

1. A Brief History of Java

  • Created by Sun Microsystems (1995): Java was developed by James Gosling and his team as a versatile, platform-independent language.
  • Core Principle - "Write Once, Run Anywhere": Java programs can run on any system with a Java Virtual Machine (JVM), making it highly portable.
  • Ownership: Oracle acquired Sun Microsystems in 2010 and now maintains Java.
  • Uses Today: Java powers Android apps, web applications, enterprise systems, IoT devices, and more.

2. Setting Up the JDK and Apache NetBeans IDE

Step 1: Install the Java Development Kit (JDK)

  1. Download the latest JDK from Oracle's official website.
  2. Run the installer and follow the prompts.
  3. Verify the installation:
    • Open your terminal/command prompt.
    • Type:
      java -version
    • You should see the installed Java version.

Step 2: Install Apache NetBeans IDE

  1. Download NetBeans from NetBeans Downloads.
  2. Install it and select the JDK directory during setup.
  3. Open NetBeans and verify the setup:
    • Go to Tools > Java Platforms to ensure the JDK is linked.

3. Writing Your First Java Program in NetBeans

Step 1: Create a New Java Project

  1. Open NetBeans.
  2. Navigate to File > New Project.
  3. Select Java > Java Application and click Next.
  4. Name your project HelloWorld, and click Finish.

Step 2: Write Your Code

  1. In the HelloWorld project, locate the HelloWorld.java file in the Projects tab.
  2. Replace the existing code with:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!"); // Print a message to the console
}
}

Step 3: Run the Program

  1. Click the green Run Project button in the toolbar or press Shift + F6.
  2. View the output in the Output Window:
    Hello, World!

Common Errors to Watch For

  1. Missing Semicolons: Ensure every statement ends with ;.
  2. Mismatched Braces: Each { must have a corresponding }.
  3. Class Name Mismatch: The class name must match the file name (e.g., HelloWorld).