The following command line causes JavaReg to register the Java class Pager:
javareg /register /class:Pager
Because /clsid:CLSID is not specified, JavaReg generates a GUID to be used as the CLSID for the class (it uses the COM API CoCreateGUID).
If you run JavaReg again with the same Java class name, it reuses the CLSID already assigned to the Java class. So you can run the tool with additional options later to reconfigure the class (for example, by specifying the /surrogate option).
The following command causes JavaReg to register the Java class Pager using the CLSID {2488D68A-D3BF-11D0-A145-080036006703}:
javareg /register /class:Pager /clsid:{2488D68A-D3BF-11D0-A145-080036006703}
The following command causes JavaReg to register the Java class Pager and assign it the ProgID called Pager.Java.1 (by default, the tool does not assign a COM ProgID to your class).
javareg /register /class:Pager /progid:Pager.Java.1
To register a JavaBean object as a Microsoft® ActiveX® Control, you can use /codebase, /control, and /typelib with /register. /codebase can be either a URL, as in this example, or a path to a directory name. If you use /control to register a JavaBean, you must also generate a type library using /typelib as shown in the following example:
javareg /register /class:Pager /codebase:http://www.reskit.com/java/trustlib /control /typelib:Pager.class
To activate and call a Java class on a different computer using Distributed Component Object Model (DCOM), use /remote on the client computer. When using this option, the Java class cannot be activated on the client computer—only on the server. The following example explains the necessary steps for using this functionality.
class Pager
{
public boolean Page(String PhoneNumber, String PIN, String Msg)
{
System.out.println("Page request received. Sending.");
System.out.println(" Phone: " + PhoneNumber);
System.out.println(" PIN: " + PIN);
System.out.println(" Message: " + Msg);
return true;
}
}
javareg /register /class:Pager /progid:Pager.Java.1 /clsid:{2488D68A-D3BF-11D0-A145-080036006703} /surrogate
javareg /register /class:Pager /progid:Pager.Java.1 /clsid:{2488D68A-D3BF-11D0-A145-080036006703} /remote:MyServer
Now you can use Microsoft® Visual Basic® to create an instance of Pager.Java.1. For example:
Dim x As Object
Set x = CreateObject("Pager.Java.1")
fSuccess = x.Page ("555-1212", "1234", "Call Home!")
The name of the remote server MyServer can be any computer identifier supported by DCOM, typically, a NetBIOS name, a DNS name, or a decimal-dotted IP address.
The Pager class will be activated and will run remotely on MyServer.