Controlling Internet Explorer from a java application, the SHDocVw.InternetExplorer object or someth

R

Richard Bell

Can it be done?
How?
Any example code?

I'd like to write a Java application that controls Internet Explorer,
downloading arbitrary pages, examining the document object, etc. I am
able to do this via VBScript in Excell, but the size of the data I'm
retrieving makes this increasingly unattractive. I'd like to use Java
instead and write data to a database file. I assume someone has
already worked out the details and am hoping for a leg up.

Thanks
 
T

Tony Morris

Richard Bell said:
Can it be done?
How?
Any example code?

I'd like to write a Java application that controls Internet Explorer,
downloading arbitrary pages, examining the document object, etc. I am
able to do this via VBScript in Excell, but the size of the data I'm
retrieving makes this increasingly unattractive. I'd like to use Java
instead and write data to a database file. I assume someone has
already worked out the details and am hoping for a leg up.

Thanks

You want to write a standalone HTTP client ? or you want to "plug-in" to IE
?

If the former, then quite simple, investigate the java.net package.

If the latter, then it's not possible - Java has no concept of "Internet
Explorer" in order to maintain platform-independance.

Sounds to me like you might need to learn some of the "ground rules" of Java
first.

--
Tony Morris
(BInfTech, Cert 3 I.T., SCJP[1.4], SCJD)
Software Engineer
IBM Australia - Tivoli Security Software
(2003 VTR1000F)
 
R

Richard Bell

I'd like to write a Java application, that interfaces to
SHDocVw.InternetExplorer (or something materially similar). I'd like
to be able to instantiate this object, use its methods, examine its
properties, etc. Think of it as a Java application that is
controlling an instance of IE.

Thanks
 
T

Tony Morris

Richard Bell said:
I'd like to write a Java application, that interfaces to
SHDocVw.InternetExplorer (or something materially similar). I'd like
to be able to instantiate this object, use its methods, examine its
properties, etc. Think of it as a Java application that is
controlling an instance of IE.

Thanks

<b>
<flash>
<read-this>
If the latter, then it's not possible - Java has no concept of "Internet
Explorer" in order to maintain platform-independance.
</read-this>
</flash>
Sounds to me like you might need to learn some of the "ground rules" of Java
first.
</i>


--
Tony Morris
(BInfTech, Cert 3 I.T., SCJP[1.4], SCJD)
Software Engineer
IBM Australia - Tivoli Security Software
(2003 VTR1000F)
 
R

Richard Bell

Tony,
I'm not interested in getting into a flame. Java has some native
interface support, JNI I think it's called, and am wondering if anyone
can give me a leg up on connecting into SHDocVW.InternetExplorer. My
understanding is that Sun provides a utility to build the interface
files from the underlying Windows DLL. Definitely not a big issue
outside any Java "ground rules". Perhaps someone else can help.
Thanks anyway.
 
T

Tony Morris

Richard Bell said:
Tony,
I'm not interested in getting into a flame. Java has some native
interface support, JNI I think it's called, and am wondering if anyone
can give me a leg up on connecting into SHDocVW.InternetExplorer. My
understanding is that Sun provides a utility to build the interface
files from the underlying Windows DLL. Definitely not a big issue
outside any Java "ground rules". Perhaps someone else can help.
Thanks anyway.

I don't want to flame either, I was just trying to make it clear.
You're right, Java does support native code, and this is by way of JNI (Java
Native Interface).
This, however, does not alter the fact that Java does not support such
constructs, you can wrap a native DLL in Java code, but then, of course, it
is platform-dependant code.

--
Tony Morris
(BInfTech, Cert 3 I.T., SCJP[1.4], SCJD)
Software Engineer
IBM Australia - Tivoli Security Software
(2003 VTR1000F)
 
R

Richard Bell

Does anyone know of a JNI wrapper for SHDocVw.InternetExplorer or
something equivalent.
 
T

Tony Morris

Does anyone know of a JNI wrapper for SHDocVw.InternetExplorer or
something equivalent.

I wasn't aware that this was, in fact, your question.
Google doesn't produce anything useful, so I doubt that such a thing
publicly exists.
It certainly wouldn't be difficult to write yourself anyway.

--
Tony Morris
(BInfTech, Cert 3 I.T., SCJP[1.4], SCJD)
Software Engineer
IBM Australia - Tivoli Security Software
(2003 VTR1000F)
 
C

Chris Smith

Richard said:
Does anyone know of a JNI wrapper for SHDocVw.InternetExplorer or
something equivalent.

I'm guessing here... You might try investigating a Java/COM bridge. It
sounds as if "SHDocVw.InternetExplorer" is a COM interface. As far as
specific Java/COM bridge products, JIntegra (expensive) and JACOB (free)
are names that get tossed around, but I don't know much about them.

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
R

Richard Bell

Thanks Chris. SHDocVw.InternetExplorer is in fact a COM object, part
of shdocvw.dll . I will probably also need interfaces to mshtml.tlb
(the DOM object lib). I'll checkout your suggestions.
 
J

Jon A. Cruz

Tony said:
This, however, does not alter the fact that Java does not support such
constructs, you can wrap a native DLL in Java code, but then, of course, it
is platform-dependant code.

Well... not quite.

You'd have to wrap a native DLL in another layer C/C++ (JNI) that gives
it a Java-style API. Then Java can call into that wrapper layer.
 
S

Sudsy

Richard said:
Can it be done?
How?
Any example code?

I'd like to write a Java application that controls Internet Explorer,
downloading arbitrary pages, examining the document object, etc. I am
able to do this via VBScript in Excell, but the size of the data I'm
retrieving makes this increasingly unattractive. I'd like to use Java
instead and write data to a database file. I assume someone has
already worked out the details and am hoping for a leg up.

Thanks

The fact that you can use VBScript to control IE shouldn't come as a
complete surprise, considering that M$ considers IE to be a part of
the program launcher. The HTML rendering engine has become so
completely integrated (yet independant?) that they're inseparable,
according to M$.
So why would you expect an O/S agnostic platform to support such
control interfaces?
Seems odd, eh?
 
R

Richard Bell

So why would you expect an O/S agnostic platform to support such
control interfaces?
Yes

Seems odd, eh?

Not really.

In MVHO, Java is a programming language. One of some several dozen
I've had occasion to use over some 40+ years of programming. I'll
have to admit to being a programming language agnostic at this point.
Language religious wars and platform perspectives aside, the ultimate
purpose of any programming language is to solve real problems in the
real world. If you live with an OS between your application and the
hardware (like almost everyone does today), then in the real world
you, from time to time, need to be able to work with that OS's
uniqueness. Likewise, other platform dependent applications are part
of the game from time to time. One measure of the strength and
utility of any language is its ability to deal with such issues with
reasonable facility and ease. Java has such a mechanism. I believe
that it's existence speaks to Java's designers desire to deal with
such issues. Indeed, while the platform remains independent, JNI
tells us that the Java language designers and interpreter implementers
knew that in the real world real programmers would need such
facilities and would, consequently, expect them to be supported within
the environment. Seems to me that there is nothing unexpected or odd
about it at all.

Just a POV from a hoary old guy with to much gray hair and way to many
languages in his past.

Richard
 
R

Richard Bell

Thanks to the JACOB clue from Tony M. I scratched around and found
http://www.nothome.com/IECanvas a project that says it puts either IE
or Mozilla in a Java canvas. I'm not sure it works, but it seems like
a big step in the right direction. It's in
http://sourceforge.net/projects/iecanvas and there is recent forum
traffic. Unfortunately, it appears as though the DOM is not fully
exposed (one of the things I need to be able to access).
 
C

Carlos Oliva

Hi Rick,
I use the JACOB libraries and works very well. AN example to control
IExplorer caomes with the download..There have been some issues with the
latest JDK's from SUN but there are fixes listed in the web site
 
R

Richard Bell

Thanks Carlos. I'd gotten that tip from Chris Smith and am working in
that direction now. I'm working on understanding the example you
mentioned. The trick seems to be understanding com.ms.com on one hand
and the com object you are using on the other.

As it happens, I've some experience in dealing with IWebBrowser2 com
object from VB inside Excell (don't ask) but need any clues I can get
re com.ms.com and it's use, and, of course getting from there to IE.

I need access to the following: the InternetExplorer object, the
object's Busy and readyState properties, the underlying document
object document, the getElementsByTagName method, the oTables.Length
method, and the document's body.innerHTML and body.innerText
properties.

If anyone has some clues, I'd appreciate it.
 
C

Carlos Oliva

Hi Richard,

The only thing that comes to mid is the Property (object?) of the Jacob
libraries. I did not have to use them but I think that you can access the
document object this way.

There is a user group for this library and questions about IExplorer surface
often. You may want to ask them also
 
R

Richard Bell

By a user group for Jacob, I assume you are refering to the Yahoo
group? Is there another?

As near as I can determine, I can use Jacob to open up an instance of
a WebBrowser object which I can then drive using automation. The
examples, while simple, are very encouraging.

Amongst the WebBrowser object properties is Document object, the
automation object of the active document, if any. When this is an HTML
page, this property provides access to the contents of the HTML
Document Object Model (DOM). It, in turn, has a great many properties
of interest including readyState (is the document fully loaded). It
also has some necessary (at least for my needs) methods including
getElementByID, getElementsByName, and getElementsByTagName. Useful
collections include links. It is these latter things I'm still
concerned about accessing. Can you provide any insight into Jacob's
abilities to access these objects/properties/methods/etc.?

Thanks for your help.

Richard
 
C

Carlos Oliva

I have not used the properties that you mention so I could not help you with
this. You may want to list this question in the user group for Jacob -- the
Yahoo group.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,821
Latest member
AleidaSchi

Latest Threads

Top