Before you begin writing Java applications, you need to set up your development environment. This includes installing the Java Development Kit (JDK) and a Java Integrated Development Environment (IDE). Once everything is installed, you can create, compile, and run your first Java program.
This guide walks you through the complete setup process on Windows.
Prerequisites
Before you begin, ensure you have:
A Windows computer
Administrator access to install software
An internet connection
Step 1: Download the Java Development Kit (JDK)
Open your web browser and visit the official Oracle Java Downloads page:
https://www.oracle.com/java/technologies/downloads/
Alternatively, you may download the latest OpenJDK release from:
Choose the latest Java LTS (Long-Term Support) version for Windows.
Step 2: Install the JDK
Open the downloaded installer.
Click Next.
Choose the installation location (or keep the default location).
Click Next to continue.
Click Install.
Wait for the installation to complete.
Click Finish.
Step 3: Verify the Java Installation
Open Command Prompt.
Run the following command:
java -version
Example output: java version "21"
Java(TM) SE Runtime Environment
Java HotSpot(TM) 64-Bit Server VM
Next, verify the Java compiler:
javac -version
Example output: javac 21
If both commands display the installed version, Java has been installed successfully.
Step 4: Download an IDE
An Integrated Development Environment (IDE) makes writing, compiling, and debugging Java applications much easier.
Popular Java IDEs include:
IntelliJ IDEA Community Edition
Eclipse IDE
Visual Studio Code (with Java Extension Pack)
For this course, IntelliJ IDEA Community Edition is recommended.
Download IntelliJ IDEA Community Edition from:
https://www.jetbrains.com/idea/download/
Step 5: Install IntelliJ IDEA
Run the installer.
Accept the default installation options.
Complete the installation.
Launch IntelliJ IDEA.
When prompted, select Community Edition.
Step 6: Create Your First Java Project
After opening IntelliJ IDEA:
Click New Project.
Select Java.
Ensure the installed JDK is selected.
Enter a project name, such as:
JavaPractice
Choose the project location.
Click Create.
Step 7: Create Your First Java Class
Inside the project:
Right-click the src folder.
Select:
New → Java Class
Enter the class name:
HelloWorld
Click OK.
Step 8: Write Your First Java Program
Replace the generated code with the following:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
This program displays the message Hello, World! on the screen.
Understanding the Program
public class HelloWorld
Defines the class named HelloWorld.
public static void main(String[] args)
This is the main method where Java begins executing the program.
System.out.println()
Prints text to the console.
Step 9: Run the Program
Click the Run (▶) button in IntelliJ IDEA.
Alternatively:
Run → Run 'HelloWorld'
The output window will display:
Hello, World!
Running a Java Program Using Command Prompt
If you prefer using the command line:
Navigate to your project folder.
Compile the Java file:
javac HelloWorld.java
Run the compiled program:
java HelloWorld
Output:
Hello, World!
Common Installation Issues
Java Command Not Found
Cause
The JDK is not installed correctly or the system PATH is not configured.
Solution
Reinstall the JDK.
Restart your computer.
Verify the installation using:
java -version
javac Command Not Found
Cause
The Java compiler is unavailable because the JDK is not installed or the PATH variable is incorrect.
Solution
Install the JDK (not just the JRE) and verify:
javac -version
JDK Not Detected in IntelliJ IDEA
Solution
Go to:
File → Project Structure → SDK
Select the installed JDK or add it manually.
Program Does Not Run
Check the following:
The class name matches the file name.
The main() method is written correctly.
There are no typing or syntax errors.
The project has been saved before running.
Verify Your Setup
Create another Java class named:
Welcome
Write the following program:
public class Welcome {
public static void main(String[] args) {
System.out.println("Welcome to Java Programming!");
}
}
Run the program.
Expected output:
Welcome to Java Programming!
If the message appears successfully, your Java development environment is ready, and you can proceed with the next lessons in the Java Programming course.
Still need help?
Contact us