![]() |
For an ActiveX client program (Visual Basic, VBScript, or ASP) to access Java classes or objects, the first step that the program must do is to create a JVM within its process. To create a JVM, the ActiveX program calls the XJBInit() method of the XJB.JClassFactory object. When an XJB.JClassFactory object is created and the XJBInit() method called, the JVM is initialized and ready for use.
The XJBInit() method accepts only one parameter; an array of Strings. Each string in the array represents a command-line argument that for a Java program you would normally specify on the Java.exe command-line. This string interface is used to set the classpath, stack size, heap size, and debug settings. You can get a listing of these parameters by typing "java -?" from the command-line.
Due to the current limitations of JNI, the JVM cannot be unloaded or reinitialized after it has been loaded. Therefore, after XJBInit() has been called once, subsequent calls have no effect other than to create a duplicate JClassFactory object for you to access. It is best to store your XJB.JClassFactory object globally and continue to reuse that object.
The following Visual Basic extract shows an example of initializing the JVM:
Dim oXJB as Object set oXJB = CreateObject("XJB.JClassFactory") Dim astrJavaInitProps(0) as String astrJavaInitProps(0) = _ "-Djava.class.path=.;c:\myjavaclasses;c:\myjars\myjar.jar" oXJB.XJBInit(astrJavaInitProps)
Related concepts... | |
Parent: How ActiveX programs use the ActiveX to EJB bridge | |
ActiveX to EJB bridge, good programming guidelines | |