The information in this article applies to:
SUMMARY
This article covers some of the Frequently Asked Questions (FAQ) about
Java/COM/DCOM.
MORE INFORMATION
Q. 1. I am trying to use an ActiveX automation object written in Java (the
COMCallingJava sample) from Visual Basic but I keep getting "Out of Memory"
errors.
Q163720: PRB: Getting Out Of Memory Error with COMCallingJava.Q. 2. Why does Java misinterpret a Boolean value that is returned by a COM object? A. This is a bug, which has been fixed with the latest Microsoft virtual machine (Microsoft VM). Please follow the link to http://www.msdn.microsoft.com to download the latest Microsoft VM. This version of the Microsoft VM requires Internet Explorer 3.01. This information is also documented in the Microsoft Knowledgebase article: Q162966 FIX: COM Object Returns Incorrect Value for BoolQ. 3. Why do I get a "java.lang.ClassFormatError", when I call Automation methods from VJ++ that takes parameters of Pointer type BSTR*, long*? A. For information on this refer to the Microsoft Knowledge Base article: Q165550 BUG: JavaTLB Generates Invalid Classes for MFC ServerQ. 4. Why do I get an "exception:java.lang.ClassCastException:xl5en32/_ExcelApplication" error, when creating a new _ExcelApplication class and type-casting it to the Application interface? A. For information on this refer to the Microsoft Knowledge Base article: Q169806 PRB: ClassCastException Error When Using Excel Object in JavaQ. 5. Do Visual J++ applets or applications support ActiveX control containment? A. Currently, the Microsoft virtual machine build 1518 does not support the containment of ActiveX controls. You cannot place an ActiveX control that has a user interface or that sources or sinks events directly onto an applet without implementing all of the ActiveX control containment and inventing interfaces yourself. To be clear, you can use ActiveX automation servers from Java, and you can write ActiveX automation servers in Java utilizing the Microsoft VM's ability to expose Java classes as ActiveX objects. You can also have ActiveX controls and Java applets on the same Web page and have them interact (see the OLEControls sample in Visual J++). However the SDK for Java 2.0x provides ActiveX Control Containment support through Beans. It exposes any Bean as an ActiveX Control and any ActiveX Control as a Bean. The SDK for Java also includes samples that illustrates how to do this. You can download this SDK from http://www.msdn.microsoft.com. Q. 6. How do I use the COMCallingJava sample as a DCOM Server? A. First you should build the sample and run it as a conventional (InProcess) automation server. Do this by following the instructions outlined in the readme.html that is installed with the sample. More information on how to use this sample via DCOM, can be found in the Knowledgebase article: Q162164: BUG: Using Java Servers and DCOMQ. 7. When I try to use JavaReg with the /surrogate switch in order to use my Automation Server written in Java as a DCOM server, the Java console pops up and closes when run on a remote machine and my client application hangs? A. You may experience various problems when you try to use an Automation Server written in Java as a DCOM server. These problems can include hanging, timeouts, out of memory errors, interface not found errors, and other errors. These errors are generally caused by not registering the Java COM object properly on both the client and DCOM server machines. The JAVAREG (version 1.0) that shipped with Microsoft Visual J++, versions 1.0 and 1.1 implemented a surrogate process itself, but it had some bugs making it difficult to setup Java DCOM servers and clients. This bug is documented in the following article in the Microsoft Knowledge Base: Q162164: BUG: Using Java Servers and DCOMThe DCOM support now in Windows 95 and Windows NT 4.0 with SP2 and SP3 supports a surrogate as part of the system, so the surrogate support with JAVAREG 1.0 has been dropped. JAVAREG 2.0 is a new tool that ships with the Microsoft SDK for Java 2.0x and this tool has fixed the bugs associated with JAVAREG 1.0 and supports remote access to a Java COM object using the system provided surrogate process. This information is also documented in the following article in the Microsoft Knowledge Base: Q173790: HOWTO: Using DllSurrogate Support for Java/DCOM ServersYou can download this SDK from http://www.msdn.microsoft.com. Q. 8. Why do I get "Failed to Create Object" error message, when trying to instantiate a COM object written in Java? A. The following is a checklist that provides some of the common causes for this error. Make sure:
A. For information on this refer to the Microsoft Knowledge Base article: Q172202 INFO: Implementing Java Automation Objects using AutoIDispatchQ. 10. Is there a way to disable this Auto IDispatch mechanism of the Microsoft virtual machine? A. You can implement the system interface com.ms.com.NoAutoScripting to disable the Auto IDispatch for all instances of a class. Q. 11. I get ComFailException:<80020005h>Type Mismatch error, when trying to use the Navigate method of the IWebBrowserApp interface? How do I invoke Internet Explorer from Java and navigate to a URL? A. The following code snippet illustrates creating a Java Object based on the Microsoft Internet Explorer and calling the Navigate method:
The Dispatch.call method is documented in the Microsoft SDK for Java
Documentation, which can be found at the following Web site:
http://www.msdn.microsoft.comQ. 12. I am able to automate Excel 7.0 from Java, but I am finding the classes and interfaces to be quite different in Excel 8. How do I automate Excel 8.0 from Java? A. For information on this refer to the Microsoft Knowledge Base article: Q169796 HOWTO: Automate Excel from JavaQ. 13. When I use JavaTLB to generate classes from some COM object libraries, I get an error J5008. Should I be concerned? A. Often, the cause of this warning is that the method uses a type that is not supported in Java. All methods that produce a J5008 warning are omitted from the class file. Note that JavaTLB has been replaced by JActiveX in the SDK for Java 2.0x. For additional information, please see the following article in the Microsoft Knowledge Base: Q167952 PRB: JavaTLB Emits J5008 Warnings for Some COM ObjectsQ.14. I get a 'java.lang.NoClassDefFoundError: com/ms/com/LicenseMgr' error when I run an applet generated by the Database Wizard for Java? A. When an applet is run in Internet Explorer and outside of Developer Studio, the applet is not trusted and does not have access to ILicenseMgr. This problem is by design since only trusted applets should have access to the ILicenseMgr. The ILicenseMgr allows the creation of COM objects on the client. To fix the problem, create a CAB file that contains the classes of the applet and digitally sign the CAB with the CodeSign kit. For more information on Cab and Sign technology, look in the "Cab&Sign" directory on the Visual J++ CD-ROM. For the latest info on CAB technology please refer to http://www.msdn.microsoft.com. For additional information, please see the following article in the Microsoft Knowledge Base: Q169810 PRB: java.lang.NoClassDefFoundError:com/ms/com/LicenseMgr ErrorQ. 15. Why does Visual Basic crash when calling a Java Object that has a method that returns a Boolean value? A. This problem has been fixed in JActiveX, where it maps VT_BOOL to a 2- byte value. You can get JActiveX, by installing the SDK for Java 2.0X from http://www.msdn.microsoft.com. Note that JavaTLB has been replaced by JActiveX in the SDK for Java 2.0X. Q. 16. When I run a Java Application that calls a COM object like an ATL Server, I get a "NoClassDeffoundError" on the COM object. The error occurs on the line where I create a new COM object in the Java Class? A. One reason why you may get this error could be related to missing parameter attributes for the methods in the ATL servers IDL file. For example if you have a method like the following example:
JavaTLB executes fine on this TLB. However when you execute your Java
Application that calls this COM object, that is ISomeInterface m_intf =
(ISomeInterface) new CAtlObj, it fails at this line with a
"java.lang.NoClassDeffoundError". To fix the problem, change the IDL method
to include the [out] attribute. For example the method looks like this:
So check your methods in the IDL file so that they have the right
attributes like [in], [out], [retval], and so on. Once you've modified the
IDL file, rebuild your ATL server, and rerun JavaTLB on the ATL Servers
Type Library so that the changes gets reflected.
For additional information, please see the following article in the Microsoft Knowledge Base: Q178560 PRB: NoClassDefFoundError Accessing a COM Object Through Java REFERENCESFor more information, please see the MSDN Web Workshop: http://msdn.microsoft.com/workshop/default.asp (c) Microsoft Corporation 1997, All Rights Reserved. Contributions by Rafael M. Munoz, Microsoft Corporation. Additional query words:
Keywords : kbcode kberrmsg kbnokeyword kbwizard kbCommandLine kbMFC kbVC kbVJ kbDSupport JCOM JVM |
Last Reviewed: July 28, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |