JRex embedded browser
by Vijay Kiran
Today I started working on JRex, and embeddable Gecko(Mozilla) browser for Java. I spent almost 3 hours to get JRexworking on my machine. I followed all the steps in the releases page.
And when I try to run the program here’s the error I got
GetNativeWindowPointer()-->
**** Inside *********** ThrowJRexException msg
Could not get JAWT, is component HEADLESS ?>
status <0> **************
JRex_ThrowByName nameorg/mozilla/jrex/exception/JRexException
msg GetNativeWindowPointer()-->Could not get JAWT, is component HEADLESS ?
[NS-ERROR<0x0L>] *******
........
After 3 hours of debugging, searching through the mailing lists, google, I couldn’t find the any solution. Here’s the code I was using to create the JRex embedded in a JFrame.
import javax.swing.JFrame; import org.mozilla.jrex.JRexFactory; import org.mozilla.jrex.exception.JRexException; import org.mozilla.jrex.ui.JRexCanvas; import org.mozilla.jrex.window.JRexWindowManager; public class TestJRex { public static void main(String[] args) throws JRexException { System.setProperty("jrex.gre.path", "c:/jrex08092005/jrex_gre/org/mozilla/jrex/jrex_gre"); JFrame frame = new JFrame(); frame.setVisible(true); JRexWindowManager winManager; JRexCanvas browser; JRexFactory.getInstance().startEngine(); winManager = (JRexWindowManager) JRexFactory.getInstance() .getImplInstance(JRexFactory.WINDOW_MANAGER); winManager.create(JRexWindowManager.TAB_MODE); winManager.init(frame.getRootPane()); browser = (JRexCanvas) winManager.getBrowserForRootParent(frame.getRootPane()).next(); // winManager.addJRexWindowListener(this); } }
And finally, here is the solution:
Eclipse was configured to use the JDK to run the java programs. But running JRex requires jre path instead of JDK directory. So I’d to change the Installed JRE’s in Eclipse to create a new JRE that points to the JRE directory instead of the JDK directory, and I set that one as the default JRE. That’s it, it solved the problem.
