Java is a statically typed, object-oriented language that compiles to bytecode running on the Java Virtual Machine (JVM). It’s widely used for enterprise applications, Android development, and backend services.
Install the JDK
macOS (Homebrew):
brew install openjdk
Ubuntu / Debian:
sudo apt-get install default-jdk
Windows: Download the JDK from Adoptium or Oracle.
Verify the installation:
java -version
# openjdk version "21.0.1" ...
Version Management
Use SDKMAN! to manage multiple Java versions:
curl -s "https://get.sdkman.io" | bash
sdk install java 21.0.1-tem
sdk default java 21.0.1-tem
Switch versions per project:
sdk use java 17.0.9-tem
Build Tools
Maven
Maven uses a pom.xml to declare dependencies and build steps:
sdk install maven
mvn archetype:generate -DgroupId=com.example -DartifactId=myapp -DarchetypeArtifactId=maven-archetype-quickstart
cd myapp
mvn compile exec:java -Dexec.mainClass="com.example.App"
Gradle
Gradle uses a build.gradle file with a Groovy or Kotlin DSL:
sdk install gradle
gradle init --type java-application
./gradlew run
Hello World
Create HelloWorld.java:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, Java!");
}
}
Compile and run:
javac HelloWorld.java
java HelloWorld
Project Structure
A typical Maven project layout:
myapp/
├── pom.xml
└── src/
├── main/
│ └── java/
│ └── com/
│ └── example/
│ └── App.java
└── test/
└── java/
└── com/
└── example/
└── AppTest.java
IDE
- IntelliJ IDEA — the most popular Java IDE (Community Edition is free)
- VS Code — with the Extension Pack for Java
- Eclipse — free, open-source IDE
Next: Java How-Tos