[Java]
Recently, the company needs encryption on a card-building project, so it needs to call the c function in java. So I studied it and referred to some examples on the Internet, I tried it myself and gave an example as follows:
Recently, the company needs encryption on a card-building project, so it needs to call the c function in java. So I studied it and referred to some examples on the Internet, I tried it myself and gave an example as follows:
Java class
[Java]
Package com. lzg;
Package com. lzg;
[Java] v
Public class Test {
Static {
System. loadLibrary ("swdes ");
}
Public native static String GenCvv (String psCardNo, String psExpiry, String psServiceCode );
/**
*
* @ Param args
* @ Author lzg
* @ Time 3:57:26
*/
Public static void main (String [] args ){
// TODO Auto-generated method stub
GenCvv ("123", "1312", "1234 ");
}
}
Public class Test {
Static {
System. loadLibrary ("swdes ");
}
Public native static String GenCvv (String psCardNo, String psExpiry, String psServiceCode );
/**
*
* @ Param args
* @ Author lzg
* @ Time 3:57:26
*/
Public static void main (String [] args ){
// TODO Auto-generated method stub
GenCvv ("123", "1312", "1234 ");
}
}
Then you need to compile it into a class
Javac Test. java
Then compile it as a. h file.
The class path of the javah-classpath project is com. lzg. Test.
Then you can get. h file, you need. the H file is handed over to c's students for development and then generated. so or. dll file, which you put into java for calling (to be improved)