惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

L
LangChain Blog
N
Netflix TechBlog - Medium
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
V
V2EX
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Blog — PlanetScale
Blog — PlanetScale
Microsoft Security Blog
Microsoft Security Blog
D
Docker
WordPress大学
WordPress大学
罗磊的独立博客
J
Java Code Geeks
博客园 - 【当耐特】
博客园 - 司徒正美
雷峰网
雷峰网
H
Help Net Security
酷 壳 – CoolShell
酷 壳 – CoolShell
Last Week in AI
Last Week in AI
宝玉的分享
宝玉的分享
Martin Fowler
Martin Fowler
T
Tailwind CSS Blog
Google DeepMind News
Google DeepMind News
M
MIT News - Artificial intelligence
Recent Announcements
Recent Announcements
B
Blog

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Modern Java Part 1: Your First Java Program in 5 Minutes
Md Jamilur Rahman · 2026-06-15 · via DEV Community

Md Jamilur Rahman

Java has been around since 1995, but modern Java (17+) is nothing like the Java your textbook taught you. It's faster, cleaner, and actually enjoyable to write.

This series covers every topic on dev.java/learn — one bite at a time. No fluff. Just what you need to know.

What You Need

Before writing code, you need two things:

1. JDK (Java Development Kit)

Download from adoptium.net — pick the latest LTS version (Java 21 or 24). Think of JDK as your Java toolbox — it has everything: compiler, runtime, and useful tools.

2. A text editor or IDE

For now, any text editor works. Later we'll set up VS Code or IntelliJ.

Your First Program

Create a file called Hello.java:

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

Breaking it down like a recipe:

  • public class Hello — A container called "Hello" (like a box with a label)
  • public static void main(String[] args) — The entry point (the "start cooking" button)
  • System.out.println(...) — Print text to screen (like console.log in JavaScript)

Run It

Open terminal, navigate to the file, and type:

javac Hello.java    # Compile: turns .java into .class (like translating a recipe into action)
java Hello          # Run: actually executes the translated code

Output:

Hello, Modern Java!

That's it. You just wrote and ran a Java program.

What Actually Happened?

Hello.java  →  javac  →  Hello.class  →  java  →  Output
  (source)     (compiler)  (bytecode)     (JVM)    (result)

Analogy: You write a recipe in English (.java). The compiler translates it into a universal language (.class bytecode). The JVM (Java Virtual Machine) reads that universal language and actually cooks the dish — on Windows, Mac, or Linux.

This "compile once, run anywhere" is Java's superpower.

What's Changed in Modern Java?

If you learned Java 8 years ago, here's what's new:

Old Java (8) Modern Java (17+)
public static void main(String[] args) void main() ✅ (yes, really!)
Verbose boilerplate everywhere Records, var, pattern matching
Slow startup Virtual Threads, CDS
Download Oracle JDK Use OpenJDK (Adoptium, Temurin)

Modern Java lets you write:

void main() {
    System.out.println("No class wrapper needed!");
}

This is called an implicitly declared class — Java 21+. No public class, no public static void main(String[] args). Just your code.

JShell — Java's Scratchpad

Instead of creating files for every experiment, use JShell — Java's interactive REPL:

jshell

jshell> 2 + 2
$1 ==> 4

jshell> "Hello".toUpperCase()
$2 ==> "HELLO"

jshell> /exit

Think of JShell as a calculator for Java. Type code, see results instantly. Perfect for testing ideas without creating files.

Key Takeaways

  1. JDK = compiler + runtime + tools — download from Adoptium
  2. Compile & Run = javac then java
  3. JVM = the magic that runs Java on any OS
  4. Modern Java = less boilerplate, more productivity
  5. JShell = your instant feedback playground

What's Next?

In Part 2, we'll set up VS Code and IntelliJ — your development environments. The right tools make everything easier.


This series follows dev.java/learn — the official Java learning path. Each article covers one topic, explained simply.