While developed completely independently of one another, it is amazing how well Java integrates with COM. Often in computing, two diametrically different technologies will be forced to coexist by brute force. However, with COM and Java it turns out that while on the surface they are diametrically opposed, they, in fact are complementary to one another.
The following table is included to help the reader make a clear distinction between what Java and COM are. Because the technologies share common attributes, such as being object-oriented and general purpose, people have attempted to somehow compare the technologies as though they attempted to solve the same problem.
Attribute | Java | COM |
Programming Language | Yes | No |
Language Independent Component Architecture | No | Yes |
Virtual Machine | Yes | No |
Simple | Yes | Yes |
Robust | Yes | Yes |
Object-oriented | Yes | Yes |
Platform Independent | Yes | Yes |
General purpose | Yes | Yes |
Multi-threaded | Yes | Yes |
Distributed | No | Yes |
Java is a great programming language for both implementing and using COM objects.
Java makes some of the more arcane and error prone aspects of COM programming easy. While Java is relatively new, it is already recognized as a great programming language. Enabling Java to create and use COM objects makes it a great programming language for COM.
COM makes Java a distributed language.
Every public Java class is a COM object and can be called remotely just like any other COM object. COM and DCOM are really the same thing--the real difference between COM and DCOM is the length of the wire between the two software components. Any COM object can be used remotely or locally; this is called location independence. Thus any COM object developed in Java can be executed on a remote server as well as on the client machine.
COM gives Java direct access to native code.
Any COM object appears to the Java programmer as a Java object. There is no need for large class libraries that wrap existing objects; the existing objects can simply be called directly.
Java and COM integrate together seamlessly.
The way that COM and Java are integrated by the Microsoft Java VM does not interfere or conflict with the "spirit" of Java in any way.
By integrating Java and COM existing technology investments are preserved while new technologies can be utilized. Java code can call, very naturally, into any ActiveX™ component, whether it's a control or Microsoft Excel. Likewise, any ActiveX™ component can call into any Java component. There is no need for new programming models and additional "layers" that technologies such as CORBA bring to the table.
Note Throughout this paper we refer to COM. When we do so we are including almost everything that has been known previously as OLE Automation. The fact is, OLE Automation was originally designed to allow higher level programming languages access to COM objects. But over time more and more of the pieces of "OLE Automation" have been utilized by various OLE initiatives to the point where those pieces are not just being used for high-level language integration.