Is it possible to use Java to build a web browser like Internet Explorer that will open all the web pages and display all the contents?
8 Answers
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.

- 37,319
- 5
- 97
- 97
-
would you like to chat with me on this topic?? – prasad Jun 17 '10 at 19:03
-
17@prasad: not to sound harsh or to demotivate you, but this is **a hell lot of** work. It wil involve years, if not a decade to achieve the level of MSIE/FF. If you're looking for partners to work on it from scratch, you're here at the wrong place. Your question is answered: it's possible. If you take a step back and elaborate a bit more about the functional requirement for which you thought that homegrowing a webbrowser is the solution, you'll probably get better suited answers how to achieve it the best way. – BalusC Jun 17 '10 at 19:12
-
@ VoteyDisciple Can you please tell why a web browser is an **exceptionally** complex piece of software ? – Suhail Gupta Aug 24 '11 at 16:54
-
5Web browsers need to interact with the network at the TCP/IP level in order to implement HTTP. They need to parse (at least) HTML, CSS, and JavaScript with a certain tolerance for errors (refusing to render a page that's missing a closing tag would break half the web). And then they need to be able to render the page while applying an infinite variety of style and layout combinations, all the while being conscious of how OTHER browsers would do it, since for better or for worse) developers may be counting on quirks they didn't even know were quirks. – VoteyDisciple Aug 25 '11 at 16:57
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.

- 37,065
- 18
- 127
- 179
-
@prasad: There's a `Source Code` link somewhere halfway the navigation menu at the website. – BalusC Jun 17 '10 at 21:11
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);

- 52
- 4

- 196,001
- 113
- 385
- 569
-
Thank u... But i did not find the setup for jdk 7. The link what u gave took me to a winrar file of jre7.. I extracted it but what should be done next??? – prasad Jun 18 '10 at 06:12
-
That's actually an alpha release, is not intended for final users. In that link there's another for source code. You can download it and read it through. Probably it would be better to wait to the formal release of JDK7 which will have a setup. – OscarRyz Jun 18 '10 at 14:25
-
@ OscarRyzHas `JWebPane` been introduced with JDK 7? I didn't find it with JDK 7 – Suhail Gupta Aug 24 '11 at 17:01
-
1@Suhail **update** It finally ended in Java FX 2.0 as *WebView* http://download.oracle.com/javafx/2.0/webview/jfxpub-webview.htm You can see other screenshots here: http://www.javamexico.org/blogs/oscarryz/webview_en_javafx – OscarRyz Aug 24 '11 at 18:43
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.

- 7,298
- 2
- 38
- 67
-
yup i actually want to learn how it can be done... I like to do things in java and so tye question arrived and i asked.... – prasad Jun 17 '10 at 19:41
Take a look at the JEditorPane
class. It can be used to render HTML pages and could form the basis of a simple browser.

- 54,009
- 15
- 113
- 152
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.

- 398,270
- 210
- 566
- 880
The hardest thing will be the rendering component. Java7 will include JWebPane, that internally uses WebKit. Here you can find some screenshots.

- 2,649
- 1
- 20
- 16
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/

- 10,311
- 4
- 47
- 47