Wallhaven CLI is a high-performance wallpaper downloader CLI tool built with Java 21 and Project Loom Virtual Threads. It searches wallhaven.cc using user-provided keywords, collects wallpaper pages through native HTML parsing, extracts original image URLs, and downloads wallpapers concurrently with real-time terminal progress tracking.
SnapVid.Net_2MuemyPVhFDazbvN_360p.mp4
- Keyword Search: Scrape and fetch images using any search term or tag directly from Wallhaven.
- Project Loom Integration: Leverages lightweight virtual threads via
Executors.newVirtualThreadPerTaskExecutor()for high-scalability, non-blocking I/O. - Terminal UI: Built with custom ANSI color states, a text-based layout, and real-time terminal progress tracking.
- No External Dependencies: Pure Java implementation utilizing native Regex-based HTML parsing and standard library network clients (
HttpURLConnection). - Zero-Crash Flow: Failures, missing images, or timed-out connections on a single wallpaper link won't halt the rest of your download queue.
- Language: Java 21+
- Concurrency: Virtual Threads,
ExecutorService,AtomicInteger,CopyOnWriteArrayList - Networking:
HttpURLConnection,URI - Parsing Engine: Native Java
PatternandMatcher(Regex-based)
Before compilation, open WallhavenDownloader.java and modify your destination path where you needed the wallpapers :
Path downloadDir = Paths.get("C:\\Users\\konda\\OneDrive\\Desktop\\wallpaper");Compile and execute the program directly using your terminal:
# Compile the application
javac WallhavenDownloader.java
# Run the utility
java WallhavenDownloaderOnce loaded, follow the interactive interface prompts:
❯ Search term → anime landscape
❯ How many → 50
❯ Threads → (default 8, press enter to skip)
Traditional multi-threaded applications require allocating heavy operating system (OS) platform threads. When downloading files, those threads spend most of their lifespans sitting idle, waiting for network packets to arrive.
This utility assigns each individual download to a Java Virtual Thread. Virtual threads are context-switched automatically by the JVM onto carrier platform threads during network blockages. This lets you spin up dozens or hundreds of parallel tasks safely and efficiently without excessive memory usage or crashing your OS task manager.