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+:
- Update Java version to 8 or higher
- Update build configuration with new jsoup version
- Test thoroughly - some deprecated methods may have been removed
- 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.