这是错误信息F:\设计\ReConserver\classes\reconserver>javah testdll
错误: 无法访问 testdll                              
找不到文件 testdll.class                             
javadoc: 错误 - 找不到类 testdll。                   
Error: 未在命令行中指定任何类。请尝试使用 -help。这是testdll.java内容:package reconserver;public class testdll {
    static{
        try{
            System.loadLibrary("System");
        }catch(Exception e){}
   }
   public native static String newprocess(String s);
   public native static String killprocess(String s);
   public native static void poweroff();
   public native static void restart();}
    

解决方案 »

  1.   

    F:\设计\ReConserver\classes\reconserver>javah testdll 
    错误: 无法访问 testdll                               
    找不到文件 testdll.class     
    ==========================================================
    在用jni调用用户类的时候,要么指定路径,要么该类位于classpath所指定的路径目录下,
    也就是说你的testdll是否能直接利用classpath找到
      

  2.   

    执行javah testdll之前,先做个如下操作:
    set classpath=.;%classpath%
      

  3.   

    没加包路径
    javah reconserver.testdll 
      

  4.   

    先检查下 java,javac好使不?
      

  5.   

    javadoc: 错误 - 找不到类 testdll要是不好使会出上面的错吗
      

  6.   

    F:\设计\ReConserver\classes>javah -jni reconserver.testdll 
      

  7.   

    首先要编译成class
    然后再用javah从.class中生成.h
    记住:必须在目录F:\设计\ReConserver\classes下。
    我执行好用了,下面是得到的头文件,文件名是:reconserver_TestDLL.h
    /* DO NOT EDIT THIS FILE - it is machine generated */
    #include <jni.h>
    /* Header for class reconserver_TestDLL */#ifndef _Included_reconserver_TestDLL
    #define _Included_reconserver_TestDLL
    #ifdef __cplusplus
    extern "C" {
    #endif
    /*
     * Class:     reconserver_TestDLL
     * Method:    newprocess
     * Signature: (Ljava/lang/String;)Ljava/lang/String;
     */
    JNIEXPORT jstring JNICALL Java_reconserver_TestDLL_newprocess
      (JNIEnv *, jclass, jstring);/*
     * Class:     reconserver_TestDLL
     * Method:    killprocess
     * Signature: (Ljava/lang/String;)Ljava/lang/String;
     */
    JNIEXPORT jstring JNICALL Java_reconserver_TestDLL_killprocess
      (JNIEnv *, jclass, jstring);/*
     * Class:     reconserver_TestDLL
     * Method:    poweroff
     * Signature: ()V
     */
    JNIEXPORT void JNICALL Java_reconserver_TestDLL_poweroff
      (JNIEnv *, jclass);/*
     * Class:     reconserver_TestDLL
     * Method:    restart
     * Signature: ()V
     */
    JNIEXPORT void JNICALL Java_reconserver_TestDLL_restart
      (JNIEnv *, jclass);#ifdef __cplusplus
    }
    #endif
    #endif
      

  8.   

    问题已经解决,谢谢
    这个正解
    F:\设计\ReConserver\classes>javah reconserver.testdll