There are many development tools, such as Java, C ++, and ,. Net, how to implement it in these different development tools
CodeIt becomes an important topic and an important means to increase productivity and reduce project costs. C ++ and. net is better integrated, because it is based on the development platform and Solutions of MS, such as COM, DLL, ActiveX, but Java and C ++ are more troublesome. The following describes how to reuse C ++ code through JNI.
1. Declare the native method in Java
Public class message {
Static {
System. Load ("C: // lib // message. dll ");
}
Public native static Boolean send (string mobile, string text );
}
Among them, the DLL name is equivalent to the DLL generated by C ++, And the send method is the code to be reused in C ++. in Java, you only need to give a declaration, the code is implemented in C ++.
2. Compile the header file
Use the javah command to generate the header files required in C ++, such.
Javah message
Note that message. Class is already used. A message. h file is generated.
3. In C ++.
Open the vc6.0 project, use Wizard to generate a DLL, include the header file generated by javah, and implement the Code to be reused. Generally, you can make a call to the encapsulated class here.
Others:
Java definitions such as Boolean and string all have corresponding conversions in JNI. H, such as jboolean, which can be directly used.
I hope to discuss it with you further.