HOME HTML EDITOR C JAVA PHP

Java Get Started: Setting Up Your Environment

Before you can start writing Java code, you need to set up your development environment. This guide will walk you through installing the JDK and running your very first Java program.

Requirement: To develop and run Java applications, you must have the Java Development Kit (JDK) installed on your system.

1. System Requirements

Modern Java versions (JDK 17 or 21 LTS) are quite efficient, but ensure your system meets these minimum specs:

2. Installing the JDK

The JDK (Java Development Kit) allows you to compile and run Java programs. Follow these steps:

Step 1: Download the JDK

Go to the official Oracle Java Downloads page. Select your operating system (Windows, macOS, or Linux) and download the x64 Installer.

Step 2: Run the Installer

Open the downloaded file and follow the installation wizard. By default, Java is installed in C:\Program Files\Java\jdk-xx on Windows.

Step 3: Verify Installation

Open your Command Prompt (CMD) or Terminal and type the following command:

java -version

If you see the version number (e.g., "java version 21"), Java is successfully installed!

3. Setting Up the PATH Variable

To run Java commands from any folder in your CMD, you must add Java to your system's Environment Variables.

  1. Search for "Edit the system environment variables" in your Windows search bar.
  2. Click on Environment Variables.
  3. Under System variables, find the variable named Path and click Edit.
  4. Click New and paste the path to your JDK's bin folder (e.g., C:\Program Files\Java\jdk-21\bin).
  5. Click OK to save everything.

4. Choosing a Text Editor or IDE

While you can write Java in Notepad, professional developers use **IDEs (Integrated Development Environments)** for better productivity.

VS Code

Lightweight and great for beginners with Java extensions.

IntelliJ IDEA

The most popular IDE for professional Java development.

Eclipse

A classic, powerful IDE used widely in the industry.

5. Your First Java Program (Hello World)

Let's write, compile, and run your first program manually to understand the process.

Step 1: Open Notepad and type the following code:

public class MyFirstProgram { public static void main(String[] args) { System.out.println("Hello World! I am learning Java."); } }

Step 2: Save the file as MyFirstProgram.java.
Important: The file name must exactly match the class name!

Step 3: Open CMD in the folder where you saved the file and type:

javac MyFirstProgram.java // This compiles the code into Bytecode
java MyFirstProgram // This runs the Bytecode

Output:

Hello World! I am learning Java.

6. Common Setup Issues

Problem Solution
'javac' is not recognized Your Environment Path is not set correctly. Refer to Step 3.
Class not found error Ensure you are running the command from the correct folder.
Wrong Case Sensitivity Java is case-sensitive. main is not the same as Main.

Everything Set Up?

Now that your computer is ready to speak Java, let's learn the basic rules of the language. In the next chapter, we will look at Java Syntax and how to write clean, error-free code.

Next: Java Syntax →