Is there a way to embed a browser in Java? more specifically, is there a library that can emulate a browser?
-
[JxBrowser](http://www.teamdev.com/jxbrowser) library provides Swing/JavaFX lightweight component based on the latest Chromium engine. The web pages are rendered by Chromium engine off-screen and displayed in the lightweight Swing/JavaFX component. It's very [easy to use](https://jxbrowser.support.teamdev.com/support/solutions/articles/9000012864-quick-start-guide-for-swing-developers). It's free for Open-Source and Academic projects. – Vladimir Sep 12 '16 at 19:42
-
i thought, it is commercial. I mean how could you get the free license @Vladimir ? – gumuruh Jan 25 '17 at 02:33
-
In the evaluation form at https://www.teamdev.com/jxbrowser#evaluate, select Open-Source or Academic. You will see short explanation: The evaluation licence will not work after this time. If you are doing an open source project, you can request a permanent licence via the link provided in the email you will receive. So, once you request evaluation, you will get an email you can write to to request a free license for open-source project. – Vladimir Jan 25 '17 at 16:28
15 Answers
-
1
-
An alternative JavaFX library is JxBrowser with BrowserView component: http://www.teamdev.com/jxbrowser – Vladimir Apr 17 '15 at 13:58
-
WebView has some performance issues, see http://stackoverflow.com/questions/10762979/performance-of-webview-in-javafx – Stefan Jan 18 '17 at 06:15
-
shitty thing ever possible. worst performance, javascript seldom works, unwanted behavior. Can never be used in any good project – Zahan Safallwa Aug 07 '17 at 14:42
-
Just tried out WebView (Jan 9, 2021), and it is now very performant! (on macOS) Very nice overall and I think I will be making GUIs via this method (also lets me embed nice javascript widgets) – Shebla Tsama Jan 09 '21 at 20:57
I believe JWebPane is going to be the official way to embed a browser into a java app. Its based on the open sourced engine - WebKit, which is used in Apples Safari and Googles Chrome browsers.See this blog for details.

- 1,433
- 2
- 14
- 19
-
1JWebPane shows no signs of activity/life... However mozswing seems to work pretty well. I tried the JNLP download version and it the page renders well. Memory usage is a high, but support for web standards is good as it is based on the Mozilla browser. Available at http://confluence.concord.org/display/MZSW/Home – Thimmayya Feb 05 '10 at 00:40
-
1As of april 2010, this is not possible. It seems JWebPane is vaporware :( – Kees Kist Apr 29 '10 at 16:37
-
1April 2011, almost, still no sign, just like JMF too, for video mission is like mission impossible. Firefox 4 is launched yesterday. – Mar 23 '11 at 18:14
-
22**Update** JWebPane changed into WebView in JavaFX 2.0 ( the libraries series ) See: http://download.oracle.com/javafx/2.0/webview/jfxpub-webview.htm for a sample screenshot of it running see: http://www.javamexico.org/blogs/oscarryz/webview_en_javafx ( not written in Java though but in a experimental JVM language ) – OscarRyz Jun 14 '11 at 21:44
-
3Is WebView in JavaFX truly standalone cross platform or does it depend on any platform specific native components? More importantly, how does it stack up to rendering pages? It is powered by WebKit but is this as close to having a real browser when it comes to rendering websites? – KJW May 07 '12 at 01:34
-
1
-
1
-
1it is possible now. Altough i am having problem with the sites using jquerry . – e13420xx Nov 04 '15 at 12:27
You could use SWT for your GUI. Its Browser control allows you to embed IE, Mozilla or Safari (depending on the platform you're running in) with little pain.

- 954
- 1
- 13
- 16
-
The return values of browser.evaluate() are limited to a view types. The JavaFx WebEngine can handle all kinds of return types by wrapping the return value in JSObject. – Stefan Jan 18 '17 at 06:17
You may try this: https://jdic.dev.java.net/
(source: java.net)
Or this: http://lobobrowser.org/java-browser.jsp
(source: lobobrowser.org)

- 21,988
- 13
- 81
- 109

- 196,001
- 113
- 385
- 569
-
Its very good to have something atleast. But its very slow and the graphics is very bad compared to Chrome or Firefox 4 – Mar 23 '11 at 17:49
-
-
@OzhanDuz any details about JDIC issues? I like the approach, but haven't used it myself yet. – Patrick Linskey Aug 21 '12 at 06:36
-
Stay away from JDIC, its not multiplatform, i am not sure but development might be stopped or not active. Use DJ Native Swing, you will get regular updates, better api and more stable. – Aug 21 '12 at 10:27
JxBrowser has not been mentionned yet. It embed either Mozilla Firefox (Gecko), Apple Safari (WebKit) or Internet Explorer. Programmer's Guide

- 6,293
- 2
- 47
- 57
-
Also [JExplorer](http://www.teamdev.com/jexplorer/) is a cheaper solution by TeamDev if you do not need a cross-platform solution. – xmedeko Sep 16 '13 at 13:25
-
2
-
I've been looking for a real answer to this question for years, and JxBrowser version 4 is really a game changer. It is exactly what you'd hope a swing browser component would be. – CarlG Apr 08 '14 at 22:19
-
1Now [JxBrowser](https://www.teamdev.com/jxbrowser) allows embedding Google Chromium engine into Java Swing/JavaFX applications. It supports two rendering modes: lightweight (off-screen) and heavyweight (GPU-accelerated). It's free for Open-Source projects. – Vladimir Jul 18 '16 at 10:07
You could also try the JWebBrowser from DJ Native Swing: http://djproject.sourceforge.net/ns

- 311
- 1
- 4
By far the most robust embeddable browser I am familiar with is the one in SWT. In fact, it is so flexible that the JavaDoc hover you can see in Eclipse is actually a browser, and the JavaDoc view actually supports things like animation!
The only risk with using SWT is that there are different versions of the SWT library for different platforms. I'm not sure if there is a singl jar you could include to cover everyone.

- 88,451
- 51
- 221
- 321
Take a look at https://xhtmlrenderer.dev.java.net/

- 2,090
- 1
- 13
- 15
-
Now known as the Flying Saucer, http://code.google.com/p/flying-saucer/ – hotzen Jan 21 '12 at 11:43
I have successfully opened a browser from Java using SWT. You can find code examples of how to use SWT to open a Browser window. It's very easy to do.

- 53,828
- 22
- 125
- 145
-
The return values of browser.evaluate() are limited to a view types. The JavaFx WebEngine can handle all kinds of return types by wrapping the return value in JSObject – Stefan Jan 18 '17 at 06:18
You can embed a browser in a Swing/AWT GUI using the JDIC API. I don't see any mention of OS X, so it may not be of use to you.

- 107,573
- 31
- 204
- 267
You could try a JEditorPane
, it doesn't interpret advanced HTML, nor Javascript, nor advanced CSS, but you can write that part yourself, called the EditorKit
. That is the class/object that is consulted by the JEditorPane or how it has to display its content.
I know its possible, because I tried and failed (:P), but it could be outdated or deprecated by now, I don't know.

- 7,356
- 12
- 48
- 71
If you need a pure Java solution then you can try JWebEngine. It render HTML 4 very good. You can use it in an applet, Java webstart and on any platform. The using is very simple.

- 23,758
- 21
- 98
- 156
-
However, it is not an open source solution. It might not fit all needs. – Vincent Cantin Feb 23 '11 at 06:22
-
Maybe Chromium Embedded Framework is an option for you. Specific to Java there is
javacef for SWT: https://github.com/wjywbs/javacef
java-cef for AWT: https://bitbucket.org/chromiumembedded/java-cef

- 10,010
- 7
- 61
- 117
You can try Webrenderer or Ice Browser

- 10,873
- 7
- 29
- 23
-
Ice Browser is not actually sold anymore, the product has reached End of Life – willcodejavaforfood Jun 23 '09 at 15:50