嵌入java应用程序的便携式网络浏览器?

发布于 2024-12-02 11:59:11 字数 183 浏览 0 评论 0原文

问题:将没有缓存的便携式网络浏览器嵌入到java应用程序中?使用 Java SE。 这可以做到吗?是否有针对 Chrome 或 Firefox 的 JNI 支持?

也许是Qt? QtJambi 允许与网络浏览器交互吗?据我了解,QtJambi 现在由社区和 LPGL 维护,QtWebbrowser 是否可以为此目的嵌入到同一许可证中?

Question: embed a portable web browser without cache into a java app? Using Java SE.
Can this be done? Are there any JNI supports for e.g. Chrome or Firefox?

Maybe Qt? QtJambi would allow interfacing with the Webbrowser? From what I understand QtJambi is now maintained by the community and LPGL, is QtWebbrowser embeddable for this purpose in the same licence?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

撕心裂肺的伤痛 2024-12-09 11:59:11

检查可用的文档,在过去的几天里出现了这样的情况:

开源浏览器是 Webkit(用于例如 Safari)和 Mozilla 风格的 Firefox。还有 Chromium,它是 Google 风格的 Chrome 的开源版本,它使用较少的 javascript 引擎(squirrel,而不是 v8),并且没有 Google Chrome 的多独立线程模块化。

有关 Firefox 的附加信息:Mozilla Firefox 基于名为 xulrunner 的应用程序,该应用程序使用 xml 和 javascript 提供 Firefox 的附加功能(除了“不太基本”的浏览器 - 例如 html 解析器、css 渲染器和 javascript 解析器) 。 Xulrunner 是浏​​览器的实现。

Firefox 实现了自己的私有 xulrunner,但另外还有 xulrunner 作为独立安装。

Xulrunner 可用于创建基于 Web 浏览器的独立应用程序,并支持 JavaScript。 Xulrunner 还用于为 Firefox 创建插件,提供附加功能。

为了将前端连接到比 javascript 更持久、更强大的东西(近年来它已经有了突飞猛进的进步),但仍然不是最强的持续引擎,有一个名为 xpcom 的 C 语言库。

Xulrunner 使用 xpcom(用 C 编写)来公开 javascript 变量并解析 dom,链接 javascript 变量,并执行其他“浏览”操作,例如读取标头等。稍后将详细介绍 Xulrunner 和 xpcom。

如果您想要一个最新且功能齐全的浏览器(html 4或5,至少对css2有良好的支持,还有一些css3,以及可靠的javascript渲染),除了编译和嵌入这些开源浏览器之一之外,您最好的选择是使用SWT。

SWT是一个gui界面,与swing类似,只不过它实现了webbrowser类型的界面,可以用来实现浏览器。 SWT 还具有一些开发的接口来与 dom 等交互。 SWT 由 IBM 开发并得到积极维护。

SWT所做的就是实现OS系统浏览器,并且支持各个主要操作系统。从好的方面来说,这意味着不需要嵌入您自己的浏览器,从坏的方面来说,您只能使用操作系统上存在的任何浏览器/解析器,无论版本如何。 Windows 操作系统上 SWT 的默认行为是使用 Internet Explorer。

还可以通过安装 xulrunner 来实现像 firefox 这样的非操作系统链接浏览器,但这需要额外的 20mb(并不广泛,但需要注意),因为最新版本的 firefox 无法识别。

在 SWT 中实现 firefox 风格的浏览器需要有 javaxpcom 支持和 xulrunner。获取 Firefox (xulrunner 1.9.) 支持的 javaxpcom 最新版本的最简单方法是下载一个名为 prism 的应用程序。 Prism 使用 xulrunner 作为基础来创建独立于特定 URL 的浏览器。有一个已知的被黑客攻击的 xulrunner 1.9.,它存在一些问题 - 如果您打算下载已经从源代码编译的 xulrunner 1.9.*,请参阅维基百科以获取相关信息。

Xulrunner 是与每个新版本的 Firefox 浏览器一起开发的。直到 v 1.9.*(firefox 3.*,如果我没记错的话),对名为 javaxpcom 的函数有额外的支持,该函数是一个为将 c 库 Xpcom 的函数链接到 java 而编写的接口。

Firefox 最初宣布嵌入和设计您自己风格的 xulrunner 是多么容易和简单,并且很容易移植到许多不同的语言(支持 C,最初支持 Java、Python 等),但显然有访问和添加库的一些开销。

Xulrunner 正在被宣传为一种潜在的软件解决方案,可以与 Java 竞争,但也受到与 javascript/html 应用程序相同的限制。它在这些参数内发挥作用。

自 xulrunner 版本 2 以来,对 javaxpcom 的支持已经减弱,因为该代码没有活跃的维护者。它是开源解决方案,因此具有必要技能的人可能会感兴趣。在撰写此答案时,Xulrunner 最近处于版本 6。然而,Xpcom 仍然表现强劲。除其他潜在问题外,推测社区的兴趣/活动不足。

由于 javaxpcom 已被报告已损坏,并且需要有人保持对代码的兴趣;这项工作必须来自对 Xulrunners xpcom 有既定了解的人,或者至少来自对 xpcom 中所做的更改有了解的人的协作。我读到的评论表明,xulrunner 上的文档可能不够详细,javaxpcom 上的文档也一样,但我无法评估这些评论。

我曾希望基本的核心功能能够简单地得到维护,从而保持最近浏览器在“可嵌入”功能改进中所涉及的艰苦工作。 Firefox 的修改导致了新版本中的扩展中断,这是与时俱进的一个功能。

嵌入 Web 浏览器等的非开源解决方案称为 webrenderer.com。它得到了维护,但附带了一个价格标签,这并不是微不足道的。

在 Java 应用程序中实现 Web 浏览器的另一种可能途径是采用名为 Qt 的跨平台开发平台。 QtJambi 是一款经过 LPGL 许可(以前是商业)的 Web 浏览器,拥有广泛的文档和对 Java 实现的支持。使用任何新平台显然都有学习曲线。从商业转向液化石油气的原因是什么?大概 Java 支持的浏览器的生存能力和商业需求已经......减弱?毫无疑问,这是我们生活的时代的一个功能。

GWT 是 java / webbrowser google 解决方案。 GWT 的工作原理是允许开发人员编写 Java 解决方案,然后将此解决方案移植并转换为可混淆的稳定 JavaScript。然而,GWT 不适合开发桌面类型应用程序,因为它需要后端的“服务器”实现。从这个意义上说,它最适合或类似于 PHP 或 ASP 风格的客户端/服务器解决方案。

虽然将 GWT 编写为桌面应用程序并非不可能,但您可能必须实现 Apache Derby、Jetty 或类似的内部服务器来完成所有来回操作。它并不简洁、优雅,也不是专门为此设计的,但已经尝试过更疯狂的解决方案。已经出现了php风格的桌面应用程序。

由于一些政治和经济动机的原因,对移植/嵌入 Java 和开源浏览器的支持似乎并不积极,这种趋势始于苹果对支持 Java 应用程序缺乏兴趣。请注意,浏览器是开源的,想必只要有足够的时间和精力,javaxpcom 等就可以持续下去,但谁会免费做这个,我不知道。

Java 承诺提供 Java 浏览器实现,但它并未随 Java 7 一起发布,并且像大多数其他事情一样需要大量工作。也许在8?即使到那时还不清楚它是否准备就绪,我也不太清楚它目前是否在路线图上,而且似乎不是他们的最高优先级。

SWT 需要一些额外的库和安装才能在各种平台上工作。

其他一些开源解决方案似乎至少部分有效,但维护、支持和当前的兴趣似乎参差不齐,包括 JRex、MozSwing。 Rhino 是一个 JavaScript 引擎,Flying Sacer 是一个 html4 渲染器。

Examining the available documentation and over the past few days this is what has emerged:

The open source browsers are Webkit (which is used for e.g. Safari), and the Mozilla flavoured Firefox. There is also Chromium which is the open source version of the Google flavoured Chrome which uses a lesser javascript engine (squirrel as opposed to v8) and does not have the multi-separate-thread modularisation of Google Chrome.

Additional information on Firefox: Mozilla Firefox is based on an application called xulrunner which uses xml and javascript to provide the additional functionality of firefox (other than the 'not so basic' browser - such things as the html parser, css renderer and javascript parser). Xulrunner is the implementation of the browser.

Firefox implements its own private xulrunner, however additionally there is xulrunner as a standalone install.

Xulrunner can be used to create standalone applications, that are based on a web-browser, and has support for javascript. Xulrunner is also used to create the plugins for firefox providing additional functionality.

In order to connect the front end to something a bit more sustained and powerful than javascript (which has improved in leaps and bounds in recent years), but is still not the strongest sustained engine, there is a C-library called xpcom.

Xulrunner uses xpcom (written in C) to expose the javascript variables and parse the dom, and link javascript variables, and do other 'browsery' things like read headers etc. More on Xulrunner and xpcom in a moment.

If you want a browser that is recent and functional (html 4 or 5, good support for css2 at least, and some css3, and solid rendering of javascript), your best bet other than compiling and embedding one of these open source browsers is to use SWT.

SWT is a gui interface, similar to swing, except that it implements a webbrowser type interface, and can be used to implement a browser. SWT also has some developed interfaces to interact both with the dom and the like. SWT was developed by IBM and is actively maintained.

What SWT does is implement the OS system browser, and has support for every major os. On the upside, this means that there is no need to embed your own browser, on the downside you are stuck with whatever browser / parsers exist on the operating systems, at whichever version. The default behaviour on a windows os for SWT is to use Internet Explorer.

It is also possible to implement non-os linked browsers like firefox by installing xulrunner, but this is an additional 20mb (not extensive but something to note), as the more recent versions of firefox are not recognised.

It is a requirement to have javaxpcom support and xulrunner to implement a firefox style browser in SWT. The easiest way to go about getting the last version supported by Firefox (xulrunner 1.9.) for javaxpcom is to download an application called prism. Prism uses xulrunner as its base to create browsers that are standalone to specific urls. There is a known hacked xulrunner 1.9. which has some issues - see wikipedia for information on this, if you aim to download xulrunner 1.9.* compiled already from source.

Xulrunner is developed alongside each and every new edition of the Firefox browser. Until v 1.9.* (firefox 3.* if I am not mistaken), there was additional support for a function called javaxpcom which was an interface written to link the c library Xpcom's functions to java.

Firefox's initial announcement of how easy and simple it was to embed and style your own flavour of xulrunner, and that it was easy to port to many different languages (support for C, initially support for Java, Python amongst others), but obviously there is some overhead to accessing and adding libraries.

Xulrunner is being promoted as a potential software solution to compete in the same playing field as java, but suffers the same limitations of javascript / html applications. Within those parameters it functions.

Since version 2 of xulrunner, support for javaxpcom has withered, as there is no active maintainer of that code. It is open source solution so presumably interest from someone with requisite skills might pick that up. Xulrunner is now recently in version 6 at the time of writing this answer. Xpcom however is still going strong. Presumably there was insufficient interest / activity in the community, amongst other potential issues.

Since javaxpcom has been reported to have broken, and requires someone to maintain an interest in the code; that work would have to come from someone who has a vested understanding of Xulrunners xpcom, or at least a collaboration from someone who has an understanding of changes made in xpcom. Comments from what I have read suggest that documentation on xulrunner may not be a detailed as it could be, nor on javaxpcom, but I am not in a position to evaluate these comments.

I had hoped that the basic core functionality could simply have been maintained, keeping the hard work involved in recent browser improvements in functionality 'embeddable'. Firefox's amendments have resulted in extensions breaking in newer versions, a function of keeping up with the times.

A non-open source solution that embeds a web-browser and the like is called webrenderer.com. It is maintained, but there is a price tag attached, which is not insignificant.

Another possible route to implement a web-browser in a java application is to go the route of a cross platform development platform called Qt. QtJambi is a LPGL licensed (previously commercial) webbrowser that has extensive documentation and support for Java implementation. There is obviously learning curve attached to using any new platform. Reasons for the move from commercial to LPGL? Presumably viability and commercial demand for java supported browsers has .... waned? A function of the times we live in no doubt.

GWT is the java / webbrowser google solution. GWT works by allowing developers to write java solutions, and then ports and converts this solution into a stable javascript that can be obfuscated. However GWT is not suited to developing a desktop type application, in the sense that it requires a 'server' implementation for the backend. In this sense it is most suited or similar to a PHP or ASP style client / server solution.

Whilst it is not impossible to write GWT as a desktop application, presumably you would have to implement Apache Derby, or Jetty or similar as an in-house server to do all the to-ing and fro-ing. Its not neat, elegant or specifically designed for this, but madder solutions have been tried. There have been php style desktop applications.

For a number of political and financially motivated reasons it appears that support for porting / embedding java and open source browsers is not on the up and up, a trend which began with apple's lack of interest in supporting java applications. Mind you, the browsers are open source and presumably with enough time and energy, javaxpcom etc. could be sustained, but who is going to do this for free, I do not know.

Java promised a java browser implementation but this was not released with the Java 7, and requires like most other things, an amount of work. Perhaps in 8? It is unclear even there if it will be ready by then, I can't quite work out if its currently on the roadmap or not, and doesn't appear to be their highest priority include.

SWT requires some additional libraries and installation to work on various platforms.

Some other open source solutions which do at least in part appear to work, but the maintenance, support and current interest in appears mixed to none, include JRex, MozSwing. Rhino is a javascript engine, flying saucer an html4 renderer.

猫九 2024-12-09 11:59:11

如果您谈论的是基于 Java SE 的应用程序,我强烈推荐 swt“浏览器”组件。我自己在基于 Eclipse RCP 的应用程序中使用过它,它的工作方式就像一个魅力(flash、javascript 支持)

If you are talking about Java SE based application I would highly recommend swt 'Browser' component. I have used it myself within Eclipse RCP based app and it works like a charm (flash, javascript support)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文