Java COM components

xiaoxiao2021-03-06  45

Operating conditions

Microsoft Java VM

Java Editor (VJ or Microsoft Java Editor)

ASP installation and run

Introduction

The MS Java virtual machine automatically treats a Java class as a method for a COM object.

You must pay attention to do some necessary data type conversions (such as: converting Java String into BSTR's).

This allows you to quickly build a basic COM component and run it.

example

Public 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 MS SDK (JVC Javacom.java).

Copy the output .class file to the / Winnt / Java / TrustLib directory.

Below, register this class into a COM object

Javaareg / register / class: javacom /progid:javacom.test

Now, we can use a Java class like a COM object, use the following statement:

Set JC = Server.createObject ("javacom.test")

Response.write jc.szhello & "
"

Response.write jc.Anyfunc & "
"

转载请注明原文地址:https://www.9cbs.com/read-79456.html

New Post(0)