2

I come from a C# background. We have something called a WebBrowser control that can load HTML Pages and interact with Javascript using C#.

I would like to interact with an HTML / Javascript page using Java. Are there any well known WebBrowser controls/objects or libraries for Java?

jeninja
  • 788
  • 1
  • 13
  • 27

3 Answers3

2

https://docs.oracle.com/javafx/2/webview/jfxpub-webview.htm I think this is the widget you're looking for. From the official JavaFX website.

vincent456
  • 102
  • 5
1

There are many options including commercial and open-source solutions.

JavaFX

JavaFX is available in Java 8-10. It provides the WebView control that you can embed into your JavaFX application to display HTML and web pages. It's based on WebKit and renders HTML off-screen using Java Graphics API. It's lightweight. In Java 11 JavaFX is no longer available. It was extracted into a separate project — OpenJFX.

Runs on Windows, macOS, Linux.

JxBrowser

It's a commercial library. It provides the BrowserView controls for Swing, JavaFX, SWT. It's based on Chromium, so the modern web pages look exactly as in Google Chrome. It supports two rendering modes: off-screen (lightweight) and hardware accelerated (GPU-accelerated, heavyweight).

Runs on Windows, macOS, Linux, Linux 64-bit ARM.

JCEF

It's an open-source library that represents Java port for CEF (C/C++). As far as I know it supports only Swing. It's based on Chromium, so the modern web pages look exactly as in Google Chrome.

Runs on Windows, macOS, Linux.


What's the difference?

In 2018 Sebastian Barth compared different Java libraries including JavaFX, JCEF, JxBrowser etc. and shared the results in the Browser Integration in Java Applications article.

Vladimir
  • 1
  • 1
  • 23
  • 30
0

One more option - https://github.com/shannah/webviewjar - very thin library, leverages the OS-built in browser, so the entire library is less than 1mb - and that's with macOS, Windows, and Linux native shims all in one jar.

Will Iverson
  • 2,009
  • 12
  • 22