The information in this article applies to:
When executing a Java application that calls a COM object like an ATL Server, you may sometimes get the following error message on the COM object:
error: java.lang.NoClassDefFoundError:
The error occurs on the line where you create a new COM object in the Java Class.
One reason why you may get this error could be related to missing parameter attributes for the methods in the COM object's IDL file.
Check your methods in the IDL file so that they have the right attributes like [in],[out],[retval] and so on. Once modifying the IDL file, rebuild your COM Server, and rerun JavaTLB or JActiveX on the COM Object's type library so that the changes gets reflected.
This behavior is by design.
........ interface ITest : IDispatch { [id(1), helpstring("Hello")] HRESULT TestMethod(BSTR* strGUID); }; ..........
............. public: STDMETHOD(TestMethod)(BSTR* a);
Following are its implementation:
// Test.cpp : Implementation of CTes .................. STDMETHODIMP CTest::TestMethod(BSTR* a) { USES_CONVERSION; *a = SysAllocString(T2OLE("This is a test!")); return S_OK; }
import atlserv.*; //This is your ATl Server Object //created in Step 1. public class Main { public static void main(String args[]) { ITest a = (ITest) new Test(); String result[]=new String[1]; a.TestMethod(result); System.out.println(result[0]); } }
Note When using SDK for Java 3.0 and newer you will get null returned.
interface ITest : IDispatch { [id(1), helpstring("Hello")] HRESULT TestMethod([out]BSTR* strGUID); };
For the latest Knowledge Base articles and other support information on Visual ++ and the SDK for Java, please see the following pages on the Microsoft Technical Support site:
http://support.microsoft.com/support/visualj/
http://support.microsoft.com/support/java/
NoClassDefFoundError atl server com