Clean • Professional
Before writing your first Java program, you need a Java Development Environment set up on your computer. This includes the Java Development Kit (JDK) and an IDE (Integrated Development Environment) like Eclipse or IntelliJ IDEA.
This guide will show you step-by-step instructions for Windows, macOS, and Linux, making it easy for beginners to start coding.
The JDK contains everything you need to compile and run Java programs, including:
javac)https://www.oracle.com/java/technologies/javase-jdk17-downloads.html
(Alternatively, you can use OpenJDK if you prefer open-source)
.exe (Windows), .dmg (macOS), or package (.tar.gz for Linux).Windows:
.exe file.C:\\Program Files\\Java\\jdk-17).macOS:
.dmg file and drag JDK to the Applications folder.java -version
Linux (Ubuntu/Debian):
sudo apt update
sudo apt install openjdk-17-jdk
java -version
Setting JAVA_HOME ensures that tools like IDE, Maven, and Gradle know where Java is installed.
Windows:
C:\\Program Files\\Java\\jdk-17)%JAVA_HOME%\\bin to the Path variable.macOS/Linux (bash/zsh):
Add to ~/.bash_profile or ~/.zshrc:
export JAVA_HOME=/path/to/jdk-17
export PATH=$JAVA_HOME/bin:$PATH
Then run:
source ~/.bash_profile
Open Command Prompt/Terminal and run:
java -version
javac -version
Expected output should show Java 17 (or your installed version).
While you can use Notepad or VS Code, a full-fledged IDE makes coding easier with:
Once your IDE is ready, create a simple Java program:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, Java Environment!");
}
}
Run the program in your IDE:
Output:
Hello, Java Environment!
Congratulations! Your Java development environment is now ready.