Table of contents

Which versions of Java are compatible with jsoup?

Java Version Requirements

Jsoup is a popular Java library for parsing and manipulating HTML documents. The Java version requirements have evolved over time as jsoup has been updated to take advantage of newer Java features.

Current jsoup Versions (1.15.0+)

Modern jsoup versions require Java 8 or higher: - Minimum: Java 8 (Java 1.8) - Required - Recommended: Java 11 or Java 17 (LTS versions) - Supported: Java 8, 11, 17, 21, and newer versions

Legacy jsoup Versions

For older Java environments: - jsoup 1.14.x and earlier: Compatible with Java 6+ - jsoup 1.13.x: Compatible with Java 6+ - jsoup 1.12.x and earlier: Compatible with Java 5+

Version Compatibility Matrix

| jsoup Version | Minimum Java Version | Latest Java Tested | |---------------|---------------------|-------------------| | 1.17.x | Java 8 | Java 21 | | 1.16.x | Java 8 | Java 21 | | 1.15.x | Java 8 | Java 19 | | 1.14.x | Java 6 | Java 17 | | 1.13.x | Java 6 | Java 15 |

Project Setup

Maven Setup

Add jsoup to your pom.xml:

<dependency>
    <groupId>org.jsoup</groupId>
    <artifactId>jsoup</artifactId>
    <version>1.17.2</version>
</dependency>

Gradle Setup

Add jsoup to your build.gradle:

dependencies {
    implementation 'org.jsoup:jsoup:1.17.2'
}

SBT Setup (Scala)

Add jsoup to your build.sbt:

libraryDependencies += "org.jsoup" % "jsoup" % "1.17.2"

Basic Usage Example

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

public class JsoupExample {
    public static void main(String[] args) throws Exception {
        // Parse HTML from URL
        Document doc = Jsoup.connect("https://example.com").get();

        // Extract title
        String title = doc.title();
        System.out.println("Title: " + title);

        // Select elements by CSS selector
        Elements links = doc.select("a[href]");
        for (Element link : links) {
            System.out.println("Link: " + link.attr("href"));
            System.out.println("Text: " + link.text());
        }
    }
}

Java Version Recommendations

For New Projects

  • Java 17 or 21: Best choice for new development
  • Use latest jsoup version for optimal performance and security

For Legacy Systems

  • Java 8: Minimum supported version for current jsoup
  • Java 6/7: Use jsoup 1.14.x or earlier versions

Performance Considerations

  • Java 11+: Better garbage collection and performance optimizations
  • Java 17+: Additional performance improvements and language features
  • Virtual threads (Java 21+): Excellent for concurrent web scraping

Checking Compatibility

Verify your Java version:

java -version
javac -version

Check jsoup version in your project:

System.out.println("jsoup version: " + org.jsoup.Jsoup.class.getPackage().getImplementationVersion());

Migration Guidelines

Upgrading from Legacy jsoup

If upgrading from jsoup 1.14.x or earlier to 1.15.x+:

  1. Update Java version to 8 or higher
  2. Update build configuration with new jsoup version
  3. Test thoroughly - some deprecated methods may have been removed
  4. Review breaking changes in the jsoup changelog

Example Migration

// Old code (jsoup 1.14.x)
Elements elements = doc.getElementsByTag("div");

// New code (jsoup 1.15.x+) - same syntax, better performance
Elements elements = doc.getElementsByTag("div");

Always verify compatibility by checking the official jsoup documentation and testing with your specific Java version before deploying to production.

Try WebScraping.AI for Your Web Scraping Needs

Looking for a powerful web scraping solution? WebScraping.AI provides an LLM-powered API that combines Chromium JavaScript rendering with rotating proxies for reliable data extraction.

Key Features:

  • AI-powered extraction: Ask questions about web pages or extract structured data fields
  • JavaScript rendering: Full Chromium browser support for dynamic content
  • Rotating proxies: Datacenter and residential proxies from multiple countries
  • Easy integration: Simple REST API with SDKs for Python, Ruby, PHP, and more
  • Reliable & scalable: Built for developers who need consistent results

Getting Started:

Get page content with AI analysis:

curl "https://api.webscraping.ai/ai/question?url=https://example.com&question=What is the main topic?&api_key=YOUR_API_KEY"

Extract structured data:

curl "https://api.webscraping.ai/ai/fields?url=https://example.com&fields[title]=Page title&fields[price]=Product price&api_key=YOUR_API_KEY"

Try in request builder

Related Questions

Get Started Now

WebScraping.AI provides rotating proxies, Chromium rendering and built-in HTML parser for web scraping
Icon