Skip to content
main
Switch branches/tags
Code

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
Oct 17, 2021
1.9
Oct 13, 2021
Sep 4, 2021
Sep 9, 2021
Oct 17, 2021

Headless-Browser

A new, headless browser for Java.

HBrowser hBrowser = new HBrowser();
try(PlaywrightWindow window = hBrowser.openWindow()){
    window.load("https://example.com");
   // ...   
}

Note that the first run may take a bit because Node.js and its modules get installed into your current working dir.

Installation

Features

  • Multiple browsers to choose from (Playwright, Puppeteer etc.)
  • Implemented GraalJS and Node.js engines
  • Jsoup for easy HTML handling
  • Supported platforms are all from Java and all from Node.js

Browsers

Name Latest JS JS-Engine Downloads Full Java
Playwright Yes Node.js/V8 Yes No
Puppeteer Yes Node.js/V8 No No
Graal Yes GraalJS No Yes

(JS = JavaScript; Full Java = If the browser is completely written in Java or not; Downloads = If the browser is able to download files other than html/xml/pdf)

Contribute/Build

Links

Examples

FAQ

What about the full Java browser?

Creating a new browser completely in Java is ongoing work (with GraalJs). Implementing all the web apis for me alone would take years, thats why I implemented Playwright into Java to have something usable right now.

If you want to contribute to the full Java browser take a look at the GraalWindow class, the GraalContext class and how to implement a js web apis.

If you are usure why to contribute to the full Java browser, read the next section below.

Why contribute to the full Java browser? I worked with multiple different browsers like JCEF, Selenium, JWebdriver, HtmlUnit and maybe some more I don't remember now, but all have one thing in common. They have some kind of caveat.

That's why I started this project. To create a new browser, not dependent on Chromium or Waterfox etc., written in Java, compatible with all operating systems that can run Java. We use Jsoup to handle HTML and the GraalJS engine to handle JavaScript.

Now you may ask: Why do you need my help? Our problem is that most of the JavaScript code out there uses so called Web-APIs: https://developer.mozilla.org/en-US/docs/Web/API , which get shipped with each browser. We will need to implement those APIs by ourselfs.

There are a lot of Web-APIs available, so we need some motivated people to implement them. If you want to help, thank you very much, already in advance! Here is a list of already implemented APIs and how to implement one: /how-to-implement-a-js-web-api.md If you are working on an implementation open an issue to keep track of who is working on what and avoid duplicate work.

What is the motivation behind this project? There are only Java browsers available that you have to buy, or they are free but come with some caveat. Thats why this project exists. We want to provide the latest and best technologies regarding headless browsers and make them available to Java applications.

Libraries

Name/Link Usage License
Playwright Emulates different types of browsers License
Puppeteer Emulates different types of browsers License
Node.js Enables executing JavaScript code License
GraalJS Enables executing JavaScript code from Java License
Jsoup Used to load pages and modify their HTML code License