简体   繁体   中英

Using java to create a web browser

Is it possible to use Java to build a web browser like Inte.net Explorer that will open all the web pages and display all the contents?

The only valid answer to that question is:

Yes, it's possible to use Java to build a web browser.

However, a web browser is an exceptionally complex piece of software. Even Google, when building its Google Chrome browser, used existing technology to do it, rather than inventing their own browser from scratch.

If your goal is anything other than building and marketing your own browser, you may want to reconsider what exactly you want to accomplish, in order to find a more direct approach.

I advise you to take a look at the Lobo Browser project, an open-source java-written web browser. Take a look at the source and see how they did it.

Yes, it is possible. JWebPane is a work in progress migration of Webkit. It is supposed to be included in JDK7 but I wouldn't hold my breath.

JWebPane browser = new JWebPane();
new JFrame("Browser").add(browser);
browser.load(someURL);

Yes, it's possible, and here's what you would need to start looking at.

First, search for an HTML renderer in Java. An example would be JWebEngine. You can start by manually downloading HTML pages and verifying that you can view them.

Second, you need to handle the networking piece. Read a tutorial on sockets, or use an HTTP Client such as the Apache HTTPClient project.

Edit: Just to add one more thought, you should be honest with yourself about why you would work on this project. If it's to rebuild IE, FF, that is unrealistic. However, what you might get out of it is learning what the major issues are with browser development, and that may be worthwhile.

Take a look at the JEditorPane class. It can be used to render HTML pages and could form the basis of a simple browser.

Yes. One of the projects in Java After Hours shows you how to build a simple web browser. It's not nearly as full-featured as IE or Firefox of course (it's only one chapter in the book), but it will show you how to get started.

The hardest thing will be the rendering component. Java7 will include JWebPane, that internally uses WebKit. Here you can find some screenshots .

I develop this browser for my college project may be this helpful for you

My Button is open source java web browser.

Develop for school and college projects and learning purpose. Download source code extract .zip file and copy “mybutton” folder from “parser\mybutton” to C:\

Import project “omtMyButton” in eclipse. Require Java 6.

Download .exe and source code : https://sourceforge.net/projects/omtmybutton/files/

There's no sense in building your own web browser in Java. It's a very complex software. I would say it's more complex than an operating system. AFAIK there are ~600 software engineers working full time on Google Chrome. I don't know how many engineers work on Mozilla Firefox and Microsoft Edge (Chromium).

So, I would recommend that you just take an existing web engine and integrate it into your Java app.

Here's the options you have, both commercial and open-source:

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 .

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).

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM