|
Web developers can use Java to make COM objects which will
provide additional features to their web applications. In this
tutorial we will compile a Java class and then we will register
it into the system registry. Later we will access
it as COM object from our web pages.
I will presume here that your operating system is Microsoft
Windows. You will need a Java compiler, you can download Java Development
Kit from java.sun.com or you can download
Microsoft's SDK for Java
. I will recommend Microsoft's SDK for Java since you will be needing javareg.exe tool
later to register your java classes as COM components.
Open your favorite notepad and write down the following Java code
exactly as it is :
class ReturnText {
public String GetText () {
return "Hello World!" ;
}
}
You may want to copy the above code and then paste it onto your
note pad. If you examine the above code, you will notice that our
above Java class is pretty much straight forward with only one
public method GetText, which returns a String "Hello World!". Now
save this file as "ReturnText.java".
| Compiling
ReturnText.java : |
Now go to the DOS prompt and compile Java class file using
the command below :
jvc ReturnText.java
A ReturnText.class file will be created if every thing goes well.
Next ->
|