The MS Java Virtual machine automatically treats the public method of a Java class as a method of a COM object.
You must be aware of the necessary data type conversions (e.g., converting Java strings to BSTRs). This allows you to quickly build a basic COM component and run it.
Examplepublic class javaCOM{
public String szHello = "Hello World" ;
public String anyFunc()
{
String n = "As returned by anyFunc !" ;
return n ;
}}
Compile this class file with Visual J + + or the MS SDK (JVC Javacom.java).
Copies the. class file of the output to the/winnt/java/trustlib directory.
Below, register the class as a COM object
Javareg/register/class:javacom/progid:javacom.test
Now, we can use a Java class like a COM object using the following statement:
Set JC = Server.CreateObject ("Javacom.test")
Response.Write Jc.szhello & "<br>"
Response.Write Jc.anyfunc & "<br>"