Last Updated: December 5, 2025
In this chapter, we will walk through the essential steps to set up a Java development environment on your machine, ensuring you have the right tools and configurations in place.
To start coding in Java, you need to install the Java Development Kit (JDK). The JDK includes everything you need to develop Java applications, including tools for compiling, debugging, and running your code.
.exe file and follow the on-screen prompts. Make sure to check the box that says “Set JAVA_HOME variable” during installation if it's available..dmg file and follow the installer instructions. You might need to set your JAVA_HOME manually afterward.After installation, you can verify that the JDK is correctly set up:
If the installation was successful, you should see the version of Java you just installed.
Setting up your environment variables is an important step that allows your system to recognize the Java commands globally. This means you can compile and run Java programs from any directory.
JAVA_HOMEC:\Program Files\Java\jdk-11.0.10).bash_profile, .bashrc, or .zshrc).To apply your changes, run:
Next, you’ll want to add the JDK's bin directory to your system's PATH:
Path variable under “System variables” and select it.bin directory (e.g., C:\Program Files\Java\jdk-11.0.10\bin).Save the file and run the appropriate source command again.
To check if your configurations are working:
You should see the path to your JDK installation. Also, running java -version should still yield the version of Java you installed.
Now that your JDK is installed and configured, the next step is picking a suitable Integrated Development Environment (IDE). An IDE is a software application that provides comprehensive facilities to programmers for software development.
Each IDE has its installation procedure:
After installing your chosen IDE, you’ll typically need to configure it to recognize your JDK installation:
Now that your environment is set up, it’s time to write your first Java program. This is a simple yet significant step in becoming familiar with the tools at your disposal.
Here’s a classic example of a simple Java program that prints “Hello, World!” to the console:
After writing the code, you’ll need to run it:
Congratulations! You’ve just compiled and run your first Java program.
As you begin your Java journey, you might encounter some common issues during setup. Here are a few troubleshooting tips:
If you get a message saying java is not recognized as an internal or external command, it’s likely a PATH issue. Double-check that the bin directory of your JDK is correctly added to your system’s PATH.
Sometimes, your IDE might not detect the JDK. Ensure that:
JAVA_HOME variable correctly.Ensure you're using a compatible JDK version with your IDE. For instance, some features in newer Java versions might not work in older IDE versions.
Now that you have successfully set up your Java environment, you are ready to explore your first Java program and see how everything comes together in practice.
In the next chapter, we will take a closer look at writing your first Java application, diving into the syntax and structure that makes Java unique.