A complete beginner's guide. No prior experience required.
A program that opens a browser, visits a website, takes a screenshot, and clicks a link. All in about 10 lines of code.
Vibium requires Java 11 or higher (we recommend the latest LTS). Check if you have it:
java --versionIf you see a version number (11.0.0 or higher), skip to Step 2.
# Install Homebrew (if you don't have it)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Install Java
brew install openjdkwinget install EclipseAdoptium.Temurin.21.JDK# Ubuntu/Debian
sudo apt-get install openjdk-21-jdk
# Or use your distro's package managermkdir my-first-bot
cd my-first-botCreate a build.gradle file:
plugins {
id 'application'
}
repositories {
mavenCentral()
}
dependencies {
implementation 'com.vibium:vibium:26.3.18'
}
application {
mainClass = 'Hello'
}mkdir my-first-bot
cd my-first-botCreate a pom.xml file:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>my-first-bot</artifactId>
<version>1.0</version>
<dependencies>
<dependency>
<groupId>com.vibium</groupId>
<artifactId>vibium</artifactId>
<version>26.3.18</version>
</dependency>
</dependencies>
</project>Download the JAR directly and compile with javac:
mkdir my-first-bot
cd my-first-bot
# Download the vibium JAR and its dependency (Gson)
curl -LO https://repo1.maven.org/maven2/com/vibium/vibium/26.3.18/vibium-26.3.18.jar
curl -LO https://repo1.maven.org/maven2/com/google/code/gson/gson/2.11.0/gson-2.11.0.jarChrome for Testing and chromedriver download automatically on first Vibium.start(). Everything is cached in a platform-specific directory:
| Platform | Cache path |
|---|---|
| Linux | ~/.cache/vibium/ |
| macOS | ~/Library/Caches/vibium/ |
| Windows | %LOCALAPPDATA%\vibium\ |
Create a file called Hello.java:
import com.vibium.Vibium;
import java.nio.file.Files;
import java.nio.file.Path;
public class Hello {
public static void main(String[] args) throws Exception {
// Launch a browser (you'll see it open!)
var bro = Vibium.start();
var vibe = bro.page();
// Go to a website
vibe.go("https://example.com");
System.out.println("Loaded example.com");
// Take a screenshot
var png = vibe.screenshot();
Files.write(Path.of("screenshot.png"), png);
System.out.println("Saved screenshot.png");
// Find and click the link
var link = vibe.find("a");
System.out.println("Found link: " + link.text());
link.click();
System.out.println("Clicked!");
// Close the browser
bro.stop();
System.out.println("Done!");
}
}# Place Hello.java in src/main/java/
mkdir -p src/main/java
mv Hello.java src/main/java/
gradle run# Place Hello.java in src/main/java/
mkdir -p src/main/java
mv Hello.java src/main/java/
mvn compile exec:java -Dexec.mainClass=Hellojavac -cp "vibium-26.3.18.jar:gson-2.11.0.jar" Hello.java
java -cp ".:vibium-26.3.18.jar:gson-2.11.0.jar" HelloYou should see:
- A Chrome window open
- example.com load
- The browser click "More information..."
- The browser close
Check your folder - there's now a screenshot.png file!
| Line | What It Does |
|---|---|
Vibium.start() |
Opens Chrome, returns a Browser |
bro.page() |
Gets the default page (tab) |
vibe.go(url) |
Navigates to a URL |
vibe.screenshot() |
Captures the page as PNG bytes |
vibe.find(selector) |
Finds an element by CSS selector |
link.text() |
Gets the element's text content |
link.click() |
Clicks the element |
bro.stop() |
Closes the browser |
Hide the browser (run headless):
import com.vibium.types.StartOptions;
var bro = Vibium.start(new StartOptions().headless(true));Use JavaScript instead: See Getting Started (JavaScript) for the JS version.
Use Python instead: See Getting Started (Python) for the Python version.
Let AI control the browser: See Agent Setup for CLI setup and Getting Started with MCP for MCP server setup.
Java isn't installed or isn't in your PATH. See Step 1 above.
Chrome for Testing downloads automatically on first use. If auto-install fails (e.g. behind a corporate proxy), see Advanced: Manual Browser Install below.
Make sure the vibium JAR is on your classpath. If using Gradle/Maven, run the build command to download dependencies first.
Try running with headless mode disabled (it's disabled by default, but just in case):
Browser bro = Vibium.start(new StartOptions().headless(false));You might need to install dependencies for Chrome:
sudo apt-get install -y libgbm1 libnss3 libatk-bridge2.0-0 libdrm2 libxkbcommon0 libxcomposite1 libxdamage1 libxfixes3 libxrandr2 libasound2By default, Chrome for Testing installs to the platform-specific cache path shown in Step 2. To change this (e.g. if your IT policy restricts writes to %LOCALAPPDATA%), set VIBIUM_CACHE_DIR:
# macOS/Linux
export VIBIUM_CACHE_DIR=/path/to/allowed/dir
# Windows (PowerShell)
$env:VIBIUM_CACHE_DIR = "C:\path\to\allowed\dir"If Chrome for Testing fails to auto-download (e.g. behind a corporate proxy), you can trigger the install manually.
java -jar vibium-26.3.18.jar installmvn compile exec:java -Dexec.mainClass=com.vibium.CLI -Dexec.args="install"Add a task to your build.gradle:
task vibiumInstall(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
mainClass = 'com.vibium.CLI'
args 'install'
}Then run:
gradle vibiumInstallCombine with environment variables as needed:
# Install to a custom directory
VIBIUM_CACHE_DIR=/path/to/dir java -jar vibium-26.3.18.jar install
VIBIUM_CACHE_DIR=/path/to/dir mvn compile exec:java -Dexec.mainClass=com.vibium.CLI -Dexec.args="install"
VIBIUM_CACHE_DIR=/path/to/dir gradle vibiumInstall
# Skip auto-download entirely (bring your own Chrome)
export VIBIUM_SKIP_BROWSER_DOWNLOAD=1You just automated a browser with Java. The same techniques work for:
- Web scraping
- Testing websites
- Automating repetitive tasks
- Building AI agents that can browse the web
Questions? Open an issue.