JRex Menu

 

 

 
 

Introduction

"JRex" is a Java Browser Component with set of API's for Embedding Mozilla Browser within a Java Application.

The goal is to provide java wrapper around the required Mozilla embedding interfaces.

You can find API Documentation for JRex here

Operating Systems

  • All Windows version that Mozilla1.4+ and Java 1.4+ supports. (Tested on WIN 98, WIN NT, WIN XP).
  • All *nix version that Mozilla1.4+ and Java 1.4+ supports with GTK support. (Tested on Red Hat Linux 7.1).
  • Mac? I don't have a Mac machine.
  • Others? Porting should be easy to other OS's, since OS dependent code is very less.

Java environments

  • JDK 1.4.1+, recommended JDK 1.4.2+.

Mozilla Version

  • Supports Mozilla 1.4+. (Has been Tested on Mozilla1.4, 1.6, 1.7).

LiveConnect Support

  • LiveConnect support in JRex is provided via JRexLiveConnectSession. JRexLiveConnectSession provides a LiveConnect bridge between trusted javascript and the JRex JVM. With JRexLiveConnectSession your java application will be able to invoke javascript on the JRexCanvas using the netscape.javascript.JSObject class, and the javascript will be able to create java classes and invoke methods on those classes. JRexLiveConnectSession differs from the java plugin in that a connection is made between javascript and the JVM that JRex was started with, instead of the JVM for the java plugin.
  • Note: JRexLiveConnectSession should only be used on a browser loaded with a web page you trust. This is because the web page will have unrestricted access to the JRex JVM. A typical usage of JRexLiveConnectSession is to use it with a custom XUL app or html page that is owned by the application.

Latest Update

  • For latest updates please check JRex news group and search for messages with subject ‘update’.

Using JRex

The test application (JRexExample.java) bundled with JRex demonstrates using of basic JRex features. All the JRex API's are well documented and can be foundhere.

Basic code for getting JRex up and running in your application is give below.

//set the system property "jrex.gre.path" to Mozilla bin directory.
System.setProperty("jrex.gre.path","C:/mozilla/bin");

//start the JRex XPCOM engine.
JRexFactory.getInstance().startEngine();

//Get the JRex WindowManager implementation.
JRexWindowManager winManager=(JRexWindowManager)JRexFactory.getInstance().getImplInstance(JRexFactory.WINDOW_MANAGER);

//Create the JRex WindowManager with desired window mode.
winManager.create(JRexWindowManager.TAB_MODE);

//init the window manager with a parent component where JRex browser sits, if component is null then a new JFrame will be used.
winManager.init(null);

//that's it ;)

Note:- Please read the JRex API documentation before using any of the above API's  

Building JRex

For building JRex, you need to build Mozilla first. See Building Mozilla.
On windows you need Visual C++ 6.0, If you want to build Mozilla on windows using GCC See Building Mozilla (GCC)

Steps I used to compile Mozilla

  • Download cygwin from cygwin.com.
  • Download JDK from sun.
  • Download ANT from Apache.
  • Download moztools from Mozilla.org
  • Download Mozilla source from Mozilla.org.
  • Set JAVA_HOME to JDK install directory.
  • Set ANT_HOME to ANT install directory.
  • Add $JAVA_HOME/bin and $ANT_HOME/bin to PATH.
  • Make a directory for moztools (E.g. c:/moztools).
  • Set MOZ_TOOLS to =c:/moztools
  • Unzip moztools download from Mozilla.org and choose install.
  • Add $MOZ_TOOLS/bin and CYGWIN/bin to PATH, if using VC++ add VCVARS32.BAT to env.
  • Make sure commands "ant, make, cl/gcc" works.
  • untar "mozilla-source-1.4.tar.bz2" via cygwin using $" tar -jxvf mozilla-source-1.4.tar.bz2 -C C:/work"
  • Create your .mozconfig file for compilation and put it inside <MOZILLA_SRC> dir , you can find "mozconfig" I used for debug/release builds.
  • Change directory into <MOZILLA_SRC> (E.g. c:/work/mozilla).
  • Enter $" make -f client.mk build all", Mozilla build should take around 1 hour depending on your system speed.
  • After build cd into <MOZILLA_SRC>/dist/bin and run mozilla.

JRex Build Requirements

On Windows

  • JDK 1.4.2+
  • ANT 1.6+
  • CYGWIN 1.5+
  • VC++ 6.0 / GCC 2.96+

On Linux

  • JDK 1.4.2+
  • ANT 1.6+
  • GCC 2.96+

JRex Build Instructions

  • Compile Mozilla and make sure that the Mozilla browser works.
  • Set "JAVA_HOME" to JDK installation path. (E.g. C:\j2sdk1.4.2_03)
  • Set "ANT_HOME" to ANT installation path. (E.g. C:\Ant)
  • Make sure that your environment "PATH" contains CYGWIN bin directory and VCVARS32.BAT if you are using VC++.
  • Copy the directory JRex into <MOZILLA_SRC>/embedding.
  • Change directory into <MOZILLA_SRC>/embedding/JRex.
  • Enter command $"ant make".
  • Enter command $"ant jrex_gre", to make custom GRE for JRex.
    • If you don't want JRex to use custom GRE edit JRex.properties and change 'jrex.gre.path' to point Mozilla bin.
    • Note:- 'jrex.app.path' property is deprecated, for now 'jrex.gre.path' and 'jrex.app.path' should point to same directory.
  • To run JRex enter $"ant run".
  • JRex native(JNI) logging is done using MACRO, if you want to disable logging remove -DJREX_DEBUG from <MOZILLA_SRC>/embedding/JRex/src/native/Makefile.in and re-compile. Aletrnatively you can use ant command $"ant makenolog" for JRex without logging.
  • Entering command $"ant dist" makes a JRex distribution.
  • Java side logging can be turned ON or OFF by setting system property JREX_DEBUG=true/false.
  • After "jrex1_0a-jrexdom" version, DOM is compiled by default, to disable JRex DOM edit JRex.properties and comment "build.dom" line.
  • Latest "jrex1_0b" version implements DOM HTML2, and HTML2 is compiled by default, to disable JRex DOM HTML2 edit JRex.properties and comment "build.dom.html2" line.
  • If you are building JRex for mozilla 1.7b and above comment out "build.1.4" line.
  • You can compile JRex with LiveConnect Support. To build JRex with LiveConnect support, edit the file "JRex.properties" and uncomment the line which sets "jrex.liveconnect". JRexLiveConnectSession builds with mozilla 1.4 and greater
  • Note:- JRex code is constantly improved and compile option may change, keep and eye on JRex news group 'greping' for messages with subject 'update'.

JRex Webstart Deployment

  • To make a WebStart package use 'ant make' followed by 'ant makews' command.
  • JRex webstart deployment is based on JRex.jnlp and JRex_GRE.jnlp.
  • JRex.jnlp is used deploy 'JRex.jar' and 'jrex.dll/libjrex.so', you can add your Application Jar which used JRex in this jnlp
  • JRex_GRE.jnlp is used deploy 'jrex_gre', by default jrex_gre is insallted into user's home directory.
  • JRex.jar and jrex_gre are deployed separatly because only JRex.jar and jrex.dll will change frequently, but jrex_gre may change only once for every mozilla release.
  • Be sure to change the codebase in JNLP if you are not using jnlp-servlet for deployment.
  • See WEBSTART SECTION in JRexExample.java on how set jrex.gre.path when running via WebStart.
  • By default JRex WebStart deployment is signed using dummy certificate, replace it with your own. Check JRex.properties for more information.


 

 

JRex- The Jed TRex







For questions or comments about jrex, please send a message to the jrex mailing list.
You can also use jrex news group.
For questions or comments not about a specific project,please read our feedback page.
This page was last updated on Jul 04, 2008.
Copyright © 2008. All rights reserved.