📄 jnicalldemo.java
字号:
public JNICallDemo {
static {
System.loadLibrary("xbfLibR");
}
public native String readRecordMsSql();
//public native String readRecordMsSql1();//
//public native String readRecordMsSql2();//
//public native String readRecordMsSql3();//
//public native String readRecordMsSql4();//
//public native String readRecordMsSql5();//
//public native String readRecordMsSql6();//
//public native String readRecordMsSql7();//
//public native String readRecordMsSql8();//
//public native String readRecordMsSql9();//
//public native String readRecordMsSql10();//
//public native String readRecordMsSql11();//
//public native String readRecordMsSql11();//
//public native String readRecordMsSql12();//
//public native String readRecordMsSql13();//
//public native String readRecordMsSql14();//
//public native String readRecordMsSql15();//
//public native String readRecordMsSql16();//
//public native String readRecordMsSql17();//
//public native String readRecordMsSql18();//
//public native String readRecordMsSql19();//
//public native String readRecordMsSql20();//
//public native String readRecordMsSql21();//
//public native String readRecordMsSql22();//
//public native String readRecordMsSql23();//
//public native String readRecordMsSql24();//
/*
*public class test {
public test() {
}
public static void main(String[] args) {
byte[] mobileno = {
0x31, 0x33, 0x36, 0x36, 0x31, 0x36, 0x33, 0x30, 0x36, 0x36, 0x37, 0x00};
String smscontentemp = "早dddddddddd文件大小258不能小于1K.原因可能是现在网络太慢或您用的浏览器不是IEddddd对于C或C++,在程序上是会有稍微的不同,这可以由读者对其进行适当的修改。这里要注意的是GetArrayLength,GetByteArrayElements等这些JNI中已经包含的方法,这些方法是专门对转换参数类型而提供的。具体的方法有很多,在下一篇中会做专门的介绍。
在完成了上述的文件后,可以对sms.c进行编译,生成.dll文件(建议在release中编译,这样动态链接库的容积会比较小!)
完成.dll文件的编译后,就可以在Java中调用C程序中的方法了。例如文件test.java ddddddd上好";
byte[] temp = {0};
try {
byte[] smscontentdb = smscontentemp.getBytes("gbk");
byte[] smscontent = new byte[smscontentdb.length + temp.length];
System.arraycopy(smscontentdb, 0, smscontent, 0, smscontentdb.length);
System.arraycopy(temp, 0, smscontent, smscontentdb.length, temp.length);
SendSMS sendSMS = new SendSMS();
sendSMS.SmsInit();
if (sendSMS.SmsSend(mobileno, smscontent) >= 0) {
System.out.println("cheng文件大小258不能小于1K.原因可能是现在网络太慢或您wwww用的浏览器不是IEgong !");
}
else {
System.out.println("shibai !");
}
}catch (Exception ex) {}
}
}
*/
/*
*public class test {
public test() {
}
public static void main(String[] args) {
byte[] mobileno = {
0x31, 0x33, 0x36, 0x36, 0x31, 0x36, 0x33, 0x30, 0x36, 0x36, 0x37, 0x00};
String smscontentemp = "早ww文件大小258不能小于1K.原因可能是现在网络太慢www或您用的浏览器不是IEww上s好";
byte[] temp = {0};
try {
byte[] smscontentdb = smscontentemp.getBytes("gbk");
byte[] smscontent = new byte[smscontentdb.length + temp.length];
System.arraycopy(smscontentdb, 0, smscontent, 0, smscontentdb.length);
System.arraycopy(temp, 0, smscontent, smscontentdb.length, temp.length);
SendSMS sendSMS = new SendSMS();
sendSMS.SmsInit();
if (sendSMS.SmsSend(mobileno, smscontent) >= 0) {
System.out.println("cheng文件大小258不能小于1K.原因www可能是现在网络太慢或您用的浏览器不是IEgong !");
}
else {
System.out.println("shi文件大小258不能小于1K.原因可能是现www在网络太慢或您用的浏览器不是IEbai !");
}
}catch (Exception ex) {}
}
}
*/
public static void main(String[] args) {
JNICallDemo jd = new JNICallDemo();
String str1;
str1 = jd.readRecordMsSql();
System.out.println(str1);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -