As someone who has worked with various scripting and programming languages; like Python, PowerShell, Perl, and C-setting up Java and compiling a basic “Hello World” application felt comfortably familiar. That said, I still believe it’s helpful to document the steps for others who may be newer to Java or just starting out in their programming journey. In this post, I’ll walk through the Java installation process, how I created and ran my first Java application, and briefly touch on the object-oriented programming (OOP) principles that make Java such a powerful language.
Step-by-Step: Installing Java (JDK)
Java programs require the Java Development Kit (JDK), which includes everything needed to compile and run Java code.
Here’s how I installed it:
Go to the Oracle JDK download page:
Download JDK for Windows
Choose the version appropriate for your system
I downloaded the Windows x64 installer for JDK 21 (or JDK 25 depending on the current release).
Install the JDK
Just run the installer and follow the prompts. Make sure to check the box that sets the JAVA_HOME environment variable during installation if prompted. This helps your system locate Java.
Verify Installation
Open Command Prompt and type:
java -version
javac -version
You should see confirmation of the Java version installed.
For Oracle’s official tutorial on this process, check out:
Java Getting Started Guide
Windows-Specific Setup Guide
Writing Your First Java Program: “Hello, World!”
To test the setup, I created a simple Java program that prints "Hello World!" to the terminal.
Tools I Used:
Notepad++ - My preferred lightweight text editor. You can also use regular Notepad, VS Code, or IntelliJ if you prefer something more advanced.
Steps I Followed:
Create the Source File
Open Notepad++ and paste the following code:
/**
* The HelloWorldApp class implements an application that
* simply prints "Hello World!" to standard output.
*/
class HelloWorldApp {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
Save the file as: HelloWorldApp.java
Make sure it’s saved with the .java extension (not .txt).
Compile the Java Program
Open Command Prompt.
Navigate to the folder where the file is saved:
cd path\to\your\file
Compile the file using:
javac HelloWorldApp.java
This will produce a HelloWorldApp.class file.
Run the Program
Still in the command line, type:
java -cp . HelloWorldApp
You should see:
Hello World!
I was pleased that it worked right away on the first attempt. The process only took about five minutes thanks to my familiarity with other languages; but even if you’re new, the steps are straightforward.
Understanding Java’s Object-Oriented Nature
Now that we’ve gotten our feet wet with a basic Java app, it’s a good time to reflect on what makes Java so widely used: object-oriented programming (OOP).
Java is built around four key OOP principles:
Encapsulation
This means bundling data and methods that operate on that data into a single unit: the class. You can hide internal details and expose only what’s needed.
Abstraction
You define complex systems using simplified models; like using interfaces or abstract classes to define behavior without committing to a specific implementation.
Inheritance
Classes can inherit properties and behaviors from other classes. This avoids redundant code and promotes reusability.
Polymorphism
This allows methods to do different things based on the object that calls them. It supports flexibility and scalable code design.
In our simple HelloWorldApp, we already touched on the concept of a class and a method. As you move forward, you’ll see how classes interact, how objects are created from them, and how OOP enables modular, testable, and maintainable code.
Resources That Helped Me
Oracle’s official Java Tutorials
Direct install from JDK Downloads
Notepad++
-My preferred editor for quick scripts
My own background and notes from previous experience
Comments
Post a Comment