This article has been archived. It is offered "as is" and will no longer be updated.
You can compile and run Visual J++ 6.0 Java-language or Microsoft COM components that are used from COM clients.
The steps in the "More Information" section describe how to manually upgrade Java-language or COM components by using a command-line tool. When you upgrade Visual J++ projects in Microsoft Visual Studio .NET, the Microsoft Visual J# Upgrade wizard automates the upgrade process for Visual J++ components.
Important If the Java-language or COM component was implemented by using the templates that are generated by the JActiveX tool, or your Java-language component implements a type library interface, you must do steps a and b before you do the numbered steps in these instructions:
Use the Tlbimp.exe command-line tool that is included with the Microsoft .NET Framework SDK and Visual Studio .NET to generate managed wrappers from the type library that you used to generate the JActiveX templates. For example, type the following at a command prompt, and then press ENTER:
In step 1 of the numbered steps, reference the managed wrapper assemblies that you generated in step a when you compile the Java-language or COM component. For example, type the following at a command prompt, and then press ENTER:
vjc /r:TlbimpGeneratedWrappers JavaSources
When you upgrade Visual J++ 6.0 Java-language or COM applications to Visual J# .NET, do not manually edit the wrappers that the JActiveX tool generated to add the .NET Framework COM interop attributes or APIs. If you manually edit these wrappers, you may experience unexpected runtime issues. Microsoft does not support the mixing of such attributes as @com and @dll with the .NET Framework COM interop attributes in Visual J++ 6.0. Microsoft strongly discourages this practice both in upgraded Visual J++ Java-language or COM applications and in new applications that are written by using Visual J# .NET.
Compile the Java-language or COM component by using the Visual J# .NET command-line compiler (Vjc.exe). For example, type the following at a command prompt, and then press ENTER to compile the code:
vjc /target:library JavaSources
Sign the assembly before you register it by using the /codebase option of the Regasm tool. To sign an assembly, attach the AssemblyKeyFile attribute that is located in the System.Reflection namespace to one of the files in your project, as in the following example:
where myKey.snk is a key pair file that the .NET Framework SDK tool Sn.exe generates.
If a COM client gains access to the Java-language or COM component by using the type library that the VJReg.exe tool generates, the COM client uses the dispinterface that is exposed on the component and . The dispIds of the class members are not guaranteed to be the same in Visual J#. If the dispIds of the class members are different from what they were in the Visual J++ version, the existing COM clients may fail. To avoid this problem, verify the following if a type library exists for the Java-language or COM component:
The type library is registered on the computer.
The GUID of the type library is specified by using the typelib parameter in the @com.register directive for the component.
In such case, a warning message appears in the Visual J# compiler.
Register the generated DLL file or EXE file by using the Regasm.exe command-line tool. (This tool is included with the Microsoft .NET Framework SDK and Visual Studio .NET.) To do this, type the following at a command prompt, and then press ENTER:
Regasm /codebase generated_DLL_or_EXE
For more information about how to upgrade Visual J++ components, visit the following Microsoft Web site: