Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Difficulty embedding mozilla using java

127 views
Skip to first unread message

scott...@gmail.com

unread,
Oct 1, 2006, 10:09:51 PM10/1/06
to
Hey guys. I'm trying to embed mozilla with java for a data gathering
tool. I don't actually need any visual elements--I just need to access
the DOM and load URLs with the browser. Regardless... I just can't
figure out how to embed mozilla. I am currently having trouble
understanding how to implement the browser chrome as well as other
interfaces so that my program actually works. What I would really like
to see is a very simple example in java of how someone would embed
mozilla.

Thanks guys,

Andy

scott...@gmail.com

unread,
Oct 2, 2006, 1:25:34 AM10/2/06
to

I'm really on the verge of giving up. I can't find any good examples
of how to embed mozilla using java. All of the code I find is
fragmented or doesn't work. Any help would be appreciated.

Marcus

unread,
Oct 2, 2006, 1:42:43 AM10/2/06
to
you may take a look to the atf project of eclipse
http://www.eclipse.org/atf/

scott...@gmail.com

unread,
Oct 2, 2006, 11:53:27 AM10/2/06
to

Thanks. I just tried to make a stripped down version using their code
to no avail though. It's giving me errors when trying to add the
progress listener and when trying to call loadURI on the web nav class.

Micael Gallego Carrillo

unread,
Oct 2, 2006, 7:24:39 PM10/2/06
to
This is about the minimum to get the mozilla dom:
Thanks to Miroslav Penkov and cancandan

import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.MozillaBrowser;
import org.eclipse.swt.browser.ProgressEvent;
import org.eclipse.swt.browser.ProgressListener;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.mozilla.xpcom.nsIDOMDocument;

public class Test {
public static void main(String args[]) {
Display display = new Display();
Shell shell = new Shell(display);

final MozillaBrowser browser = new
MozillaBrowser(shell,WT.BORDER);
browser.setUrl("http://www.google.com");
browser.addProgressListener(new ProgressListener() {
public void changed(ProgressEvent event) {
}

public void completed(ProgressEvent event) {
nsIDOMDocument doc = browser.getDocument();
System.out.println(doc);
}
});

while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
}

scott...@gmail.com escribió:

scott...@gmail.com

unread,
Oct 4, 2006, 8:01:05 PM10/4/06
to
Is there any way to do that without having a GUI?

Ben Hutchings

unread,
Oct 7, 2006, 6:38:03 PM10/7/06
to
<scott...@gmail.com> wrote:
> Is there any way to do that without having a GUI?

The browser is inherently a GUI component. However, if the underlying
GUI supports some kind of off-screen or hidden window, then the browser
can probably be made to use that. Under Linux I'm using Xvfb (X virtual
frame buffer server) to run the browser without a real display.

Ben.

--
Ben Hutchings -- b...@decadentplace.org.uk shortened to b...@decadent.org.uk
If you've signed my GPG key, please send a signature on and to the new uid.
I'm not a reverse psychological virus. Please don't copy me into your sig.

Andy Scott

unread,
Oct 7, 2006, 7:44:41 PM10/7/06
to
Yes, that is true. But I have read that it is possible to implement
the window classes so that there is no rendered GUI. How do to do this
I don't know.
0 new messages