In addition, turn two article 1,-----------------------------Java invoke COM notes download jcom, extract Jcom.jar and jcom.dll two files. 1, Copy the Jcom.jar of the attachment to the local, and set the environment variable reference (the simplest and quickest way is to extract the jar package into its own code directory). 2, The DLL copy to the JDK directory in the bin directory. 3, Find the COM master name that needs to be invoked. Note that the COM component name is not the name of the DLL file and can be queried in the registry. 4. Lookup COM interface method: You can refer to the corresponding DLL in Microsoft Visual Studio. NET 2003, and you can see all the interface methods for that component in the Object Browser: 5, java calling code: Impo RT jp.ne.so_net.ga2.no_ji.jcom.*; public class Processxml { public static void main (string[] args) { Process (); } public static String Process () { &NBS P Releasemanager rm = new Releasemanager (); try { IDispatch vbcom = New IDispatch (rm, "U8distribute.idistribute"); object[] param = new object[] {"XXXXX"}; String strret = (String) vbcom.method ("Process", param); &NBSP;SYSTEM.OUT.PRINTLN ("retur N: " + strret); catch (Exception e) { &NBSP ; e.printstacktrace (); finally { &NBSP ; rm.release (); return null; } 2,-----------------------------------http://www.chinaunix.net/jh/26/272195.html use vc+ +6.0 The simplest example of JNI implementation. Http://www.chinaunix.net Author: ludejun98 Posted in: 2004-03-03 11:16:06 the latest project design to JNI technology, for VC + + I was a smattering. JNI is an interface that knows and native methods, and has never been used before. But for a while, or feel a bit of a way, to fix the problem of JNI, for their own this little progress dare not conceal, openCome out and give a reference to the brothers who don't know. Use JNI to invoke DLL 1 in Java to write an example document public class testnative{ private native int add (int x,int y); public St atic void Main (string[] args) { testnative hh = new testnative (); int r = Hh.add (30,20); &NBSP;SYSTEM.OUT.PRINTLN ("result =" +r); &NBSP} static { system.loadlibrary ("dll_0305"); }} The name of the DLL file in the LoadLibrary can be arbitrarily determined. As long as a good dynamic link library renamed to this string can be. The native function is derived from this dynamic link library. 2. After this step is ready, use Javac Testnative.java to generate. class. Test syntax. 3. After the grammar check passes, uses the Javah testnative to generate. h's C header file. 4. Open vc++6.0, New-> project-> Win32 Dynamic-link Library. Select an empty project in the wizard. 5. Add the header file that you just javah to the project. Then the file-> new->textfile to make a. c file. Implement your own native function. The list is as follows: #include <jni.h> jniexport jint Jnicall java_testnative_add (jnienv *ev, Jobject obj, Jint x, Jint y) {return x+y;} notes: A jni.h of which is usually jdk/in clude/can be copied to the VC installation directory under the Include directory. Once and for all, you can easily use JNI technology later. B All data types need to consider Java and VC interface issues. Use the Jint jstring and so on. C function names are consistent with those provided in the auto-generated. h file. The naming rule is: Java_Use class _ Method name 6 to compile the project completely. If there are no errors, the dynamic link library is generated successfully at this time. Copy the dynamic link library to the directory where Testnative.java resides. 7 run Java testnative see results.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.