Ugenz Academy/Tutorial

Setup

3 min read545 words

Reading progress

Keep learning

Java Setup

Introduction

Before writing and running Java programs, we need to install the Java Development Kit (JDK) on our computer.

The JDK provides the tools required to write, compile, and run Java programs.

Requirements

To start Java programming, you need:

  • A computer or laptop
  • Java Development Kit (JDK)
  • A code editor or IDE
  • Command Prompt or Terminal

Step 1: Install JDK

Download and install a suitable version of the JDK for your operating system.

After installation, Java provides important commands such as:

java javac
  • java → Runs a Java program.
  • javac → Compiles Java source code.

Step 2: Check Java Installation

Open Command Prompt on Windows or Terminal on Linux/macOS.

Type:

java -version

You should see information about the installed Java version.

Then check the Java compiler:

javac -version

If both commands display a version number, Java has been installed successfully.

Step 3: Set JAVA_HOME

JAVA_HOME is an environment variable that tells software where the JDK is installed.

For example, on Windows:

C:\Program Files\Java\jdk-XX

The exact folder name depends on the JDK version you installed.

Step 4: Add Java to PATH

The Java bin directory should be available in the system PATH.

For example:

C:\Program Files\Java\jdk-XX\bin

This allows commands such as java and javac to be executed from any directory.

Step 5: Install a Code Editor

You can write Java programs using:

  • Visual Studio Code
  • IntelliJ IDEA
  • Eclipse
  • NetBeans
  • Notepad

For beginners, Visual Studio Code or IntelliJ IDEA are good choices.

Step 6: Create Your First Java Program

Create a file named:

HelloWorld.java

Write the following code:

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

Step 7: Compile the Program

Open Command Prompt or Terminal in the folder containing the file.

Run:

javac HelloWorld.java

If there are no errors, Java creates:

HelloWorld.class

The .class file contains Java bytecode.

Step 8: Run the Program

Run the compiled program using:

java HelloWorld

Output:

Hello, World!

Java Compilation Process

HelloWorld.java ↓ javac ↓ HelloWorld.class ↓ JVM ↓ Hello, World!

Common Errors

1. java is not recognized

This usually means Java is not correctly added to the PATH.

Check your JDK installation and environment variables.

2. javac is not recognized

This usually means the JDK's bin directory is not available in the PATH.

3. Class name error

The public class name should match the Java filename.

Correct:

HelloWorld.java
public class HelloWorld { }

Incorrect:

Test.java
public class HelloWorld { }

Useful Commands

CommandPurpose
java -versionCheck Java version
javac -versionCheck compiler version
javac FileName.javaCompile Java program
java FileNameRun Java program

Conclusion

Setting up Java requires installing the JDK, checking the Java installation, configuring the PATH when necessary, and using a code editor or IDE. After setup, you can create, compile, and run Java programs on your computer.

Keep learning. Keep building. Keep growing.

© 2026 Ugenz Academy