Home : Embedding Internet Explorer in a Java Frame
Q52227 - HOWTO: Embedding Internet Explorer in a Java Frame

Embedding Internet Explorer in a Java Frame

 

This example embeds Internet Explorer inside a JFrame, navigates to an HTML document, and reads/displays the tags in the document to the command prompt. To run this example you will need the Java proxies generated from the mshtml type library, as well as the main Internet Explorer typelibrary (shdocvw.dll).

We assume that you are familiar with Java -- no COM knowledge should be required. You may wish to run through some of the more detailed step-by-step examples in the J-Integra documentation (such as the Excel example) prior to trying this example. We assume you have already downloaded and installed the J-Integra SDK.

Steps:
1. Configure your Environment
2. Download the Java proxies
3. Run the Example

Step 1: Configure your Environment

Create a new folder to where the HTMLDocumentParser.java source file will be downloaded. We assume that you have already configured your DCOM settings and environment variables such as Path and Classpath.

Step 2: Download the Java proxies

We have already generated the Java proxies needed for this example (they can be downloaded below). The two files you need to download are mshtml.zip and shdocvw.zip. Please unzip these files in the same directory as where you saved HTMLDocumentParser.java.

Important:

Because this example embeds WebBrowser ActiveX Control in a Java frame, the Java proxies of shdocvw.dll are generated with com2java option Generate Java AWT classes turned on. If your Java client does not embed the WebBrowser ActiveX Control and only accesses the InternetExplorer object, you must turn off the option Generate Java AWT classes, regenerate the Java proxies for shdocvw.dll, and use the InternetExplorer object instead of the WebBrowser object in your Java client. Please use this example instead.

Step 3: Run the Example

Remember to include the \jre\bin directory in your PATH environment variable:

set PATH=C:\java\j2sdk1.4.2\bin;C:\java\j2sdk1.4.2\jre\bin;C:\jintegra\bin;%PATH%

Make sure your CLASSPATH includes jintegra.jar, and then update and compile HTMLDocumentParser.java. If you get compilation errors then either your CLASSPATH is incorrect or your proxies do not have the right package names. After compiling the example, enter the following at the command prompt. The URL can be the address of any website.

java -DJINTEGRA_COINIT_VALUE=2 HTMLDocumentParser http://j-integra.intrinsyc.com

Note:

Due the nature of the WebBrowser ActiveX control (shdocvw.dll), the WebBrowser object ignores certain properties including AddressBar, MenuBar, ToolBar, etc. Therefore, if you use these calls (setAddressBar, setMenuBar, setToolBar, etc) with a WebBrowser control it will ignore these calls (but return no error).

MSDN Reference: http://msdn.microsoft.com/en-us/library/aa752043(VS.85).aspx

You will need to implement these controls and buttons yourself. Possible solutions are:

1. Implement them in a Java GUI, such as Swing.

2. Implement them in a VB ActiveX control, then generate Java proxies for this control using com2java.

Related Articles
No Related Articles Available.

Article Attachments
mshtml.zip
HTMLDocumentParser.java
shdocvw.zip

Related External Links
No Related Links Available.
Help us improve this article...
What did you think of this article?

poor 
1
2
3
4
5
6
7
8
9
10

 excellent
Tell us why you rated the content this way. (optional)
 
Approved Comments...
No user comments available for this article.
Created on 6/23/2006.
Last Modified on 12/11/2009.
Last Modified by J-Integra KB Admin.
Article has been viewed 15924 times.
Rated 6 out of 10 based on 15 votes.
Print Article
Email Article