private native String nativeOpenOffline(String filename);
用native关键字就可以实现调用c的函数。
Native methods :Native indicates that a method is written in a platform-dependent language to perform a platform specific function that cannot be handled in Java. You will not need to know how to use native methods for the exam, other than knowing that native is a reserved keyword.

解决方案 »

  1.   

    你说情况,直接在java中调用c语言编译的exe文件就可以了。
    示例:
    class try{
      public static void main(String args[]){
    try{
    Runtime.getRuntime().exec("cmd /c start ***.exe");
    }
    catch (Exception e){
    System.out.println("the call .exe file failed!");
    }
      }
    }
      

  2.   

    看你的情况同意
    superLee(superLee)
      

  3.   

    同意superLee,
    根据情况,来定
      

  4.   

    介绍一下C,c++的调用
    文件一 HelloNative.java
    class HelloNative
    {  public static native void greeting();
       static
       {  System.loadLibrary("DllTest");
        // 此处DllTest是一个动态链接库DllTest.dll
       }
    }
    // 编译成.class 然后用 dos 命令 javah HelloNative,生成HelloNative.h头文件
    内容如下
    /* DO NOT EDIT THIS FILE - it is machine generated */
    #include <jni.h>
    /* Header for class HelloNative */#ifndef _Included_HelloNative
    #define _Included_HelloNative
    #ifdef __cplusplus
    extern "C" {
    #endif
    /*
     * Class:     HelloNative
     * Method:    greeting
     * Signature: ()V
     */
    JNIEXPORT void JNICALL Java_HelloNative_greeting
      (JNIEnv *, jclass);#ifdef __cplusplus
    }
    #endif
    #endif
    ----------------------------
    之后,用C实现方法
    JNIEXPORT void JNICALL Java_HelloNative_greeting
      (JNIEnv* env, jclass cl)
    { ............... }
    并将它生成DllTest.dll
    ok了