肯定回答:能,
不过我还没有搞懂
郁闷学习ing

解决方案 »

  1.   

    Write the Java code. We'll start by writing Java classes to perform three tasks: declare the native method we'll be calling; load the shared library containing the native code; and call the native method.
    Compile the Java code. We must successfully compile the Java class or classes to bytecode before we can use them.
    Create the C/C++ header file. The C/C++ header file will declare the native function signature that we want to call. This header will then be used with the C/C++ function implementation (see Step 4) to create the shared library (see Step 5).
    Write the C/C++ code. This step consists of implementing the function in a C or C++ source code file. The C/C++ source file must include the header file we created in Step 3.
    Create the shared library file. We'll create a shared library file from the C source code file we created in Step 4.
    Run the Java program. We'll run the code and see if it works. We'll also go over some tips for dealing with the more commonly occurring errors. 
      

  2.   

    public class Sample1
      {
        public native int intMethod(int n);
        public native boolean booleanMethod(boolean bool);
        public native String stringMethod(String text);
        public native int intArrayMethod(int[] intArray);
     
        public static void main(String[] args)
        {
         System.loadLibrary("Sample1");
         Sample1 sample = new Sample1();
         int     square = sample.intMethod(5);
         boolean bool   = sample.booleanMethod(true);
         String  text   = sample.stringMethod("JAVA");
         int     sum    = sample.intArrayMethod(
                             new int[]{1,1,2,3,5,8,13} );     System.out.println("intMethod: " + square);
         System.out.println("booleanMethod: " + bool);
         System.out.println("stringMethod: " + text);
         System.out.println("intArrayMethod: " + sum);
       }
     }
      

  3.   

    javac Sample1.javajavah Sample1 will see/* DO NOT EDIT THIS FILE - it is machine generated */
      #include <jni.h>
      /* Header for class Sample1 */
      
      #ifndef _Included_Sample1
      #define _Included_Sample1
      #ifdef __cplusplus
      extern "C" {
      #endif JNIEXPORT jint JNICALL Java_Sample1_intMethod
       (JNIEnv *, jobject, jint); JNIEXPORT jboolean JNICALL Java_Sample1_booleanMethod
       (JNIEnv *, jobject, jboolean);
     
     JNIEXPORT jstring JNICALL Java_Sample1_stringMethod
      (JNIEnv *, jobject, jstring); JNIEXPORT jint JNICALL Java_Sample1_intArrayMethod
      (JNIEnv *, jobject, jintArray);
     
     #ifdef __cplusplus
     }
     #endif
     #endif
      

  4.   

    参考(Impylm(韩冰))你的例子,出现了如下错误,望再次解答java.lang.UnsatisfiedLinkError: SmsSendMsg at aboutgsm.SMSDLL.SmsSendMsg(Native Method) at aboutgsm.SMSDLL.main(SMSDLL.java:38)Exception in thread "main" 
    SmsSendMsg 是DLL 提供的函数!