"Getting Started with Java: A Beginner's Guide to Running Java Programs"

Gerald Jun 16, 2026

Getting Started with Java

How To Run A Java Program In Windows 10+ ?
How To Run A Java Program In Windows 10+ ?

Java is a popular, object-oriented programming language that's widely used for developing large-scale applications, including Android apps, web applications, and enterprise software. To run Java, you'll need to have the Java Development Kit (JDK) installed on your computer. The JDK includes the Java Runtime Environment (JRE), which provides the libraries and tools needed to run Java programs.

a poster with different types of writing and numbers on it, including the words'jwa beginner notes '
a poster with different types of writing and numbers on it, including the words'jwa beginner notes '

Prerequisites

Before you can start running Java, you'll need to meet the following prerequisites:

Java Program Structure Explained ☕ | Beginner-Friendly Guide
Java Program Structure Explained ☕ | Beginner-Friendly Guide
  • A computer with a 64-bit operating system (Windows, macOS, or Linux)
  • The Java Development Kit (JDK) installed on your computer
  • A text editor or IDE (Integrated Development Environment) such as Eclipse, NetBeans, or IntelliJ IDEA

Installing the JDK

Java RoadMap
Java RoadMap

To install the JDK, follow these steps:

Configuring the JDK

How to Count Vowels in Java | Simple Code Example
How to Count Vowels in Java | Simple Code Example

After installing the JDK, you'll need to configure it to work with your IDE or text editor. The steps for this will vary depending on your chosen IDE or text editor, so consult the documentation for your specific tool.

Writing and Compiling Java Code

To run Java, you'll need to write and compile Java code. Here's a basic example of a Java program that prints "Hello, World!" to the console:

the roadmap to learn java from zero - to - job ready info sheet
the roadmap to learn java from zero - to - job ready info sheet

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

To compile this code, open a terminal or command prompt and navigate to the directory where you saved the code. Then, type `javac HelloWorld.java` to compile the code. If you don't have a Java compiler installed, you'll need to add the JDK's bin directory to your system's PATH environment variable.

Running Java Code

Complete Java Cheat Sheet for Beginners to Advanced Developers
Complete Java Cheat Sheet for Beginners to Advanced Developers
Home
Home
✨ Complete Java Backend Roadmap for Beginners
✨ Complete Java Backend Roadmap for Beginners
✨ Learn Java in 30 Days – Beginner Friendly Guide
✨ Learn Java in 30 Days – Beginner Friendly Guide
Java Virtual Machine Explained: Run Your Code Anywhere!
Java Virtual Machine Explained: Run Your Code Anywhere!
Java Beginner Cheetsheet
Java Beginner Cheetsheet
How to Run a Java Program from the Command Prompt - Make Tech Easier
How to Run a Java Program from the Command Prompt - Make Tech Easier
🚀 JVM, JRE, and JDK in Java Explained! 💻
🚀 JVM, JRE, and JDK in Java Explained! 💻
Steps to becoming a java pro
Steps to becoming a java pro
Java CRUD Operation | Short Revision
Java CRUD Operation | Short Revision
Interface in Java
Interface in Java
Beginner Java Projects Roadmap
Beginner Java Projects Roadmap
an image of a text description for a web page
an image of a text description for a web page
Java Notes
Java Notes
Java Basics Cheat Sheet | Core Java Programming Notes for Beginners | AKTU Notes
Java Basics Cheat Sheet | Core Java Programming Notes for Beginners | AKTU Notes
Java Roadmap for Beginners 2026
Java Roadmap for Beginners 2026
the info sheet shows different types of programming
the info sheet shows different types of programming
How to Run Java Program In Cmd Using Notepad - Learnprogramo
How to Run Java Program In Cmd Using Notepad - Learnprogramo
Java Programming Cheat Sheets, Java Programming Language Cheat Sheet, Java For Basics Cheat Sheet, Java Cheat Sheet Pdf Download, Basic Java Data Cheat Sheet, Java Cheat Sheet Pdf, Java Cheatsheet, Functional Programming In Java, What Is Functional Programming In Java
Java Programming Cheat Sheets, Java Programming Language Cheat Sheet, Java For Basics Cheat Sheet, Java Cheat Sheet Pdf Download, Basic Java Data Cheat Sheet, Java Cheat Sheet Pdf, Java Cheatsheet, Functional Programming In Java, What Is Functional Programming In Java
Two Pointer Algorithm Explained in Java | Coding Interview Must Know
Two Pointer Algorithm Explained in Java | Coding Interview Must Know

To run the compiled Java code, type `java HelloWorld` in the terminal or command prompt. If everything is set up correctly, you should see the output "Hello, World!" printed to the console.

Troubleshooting

If you're having trouble running Java, here are some common issues and solutions:

Issue Solution
Error message "java: not found" Add the JDK's bin directory to your system's PATH environment variable
Error message "java: invalid flag: -version" Check that you're using the correct Java compiler (javac or java)

Best Practices

Here are some best practices to keep in mind when running Java:

  • Use a consistent naming convention and follow Java coding standards
  • Use meaningful variable names and avoid using abbreviations
  • Use try-catch blocks to handle exceptions and errors
  • Use comments to explain complex code and logic

By following these best practices and using the right tools and techniques, you'll be well on your way to becoming proficient in Java and developing high-quality software applications.