Java 有没有针对硬件的开发呢? 或有人用Java做过针对硬件的开发吗? 请指点!!!

解决方案 »

  1.   

    可以肯定是可以,不过一般要使用jni。调用其它语言(如c++)开发的dll。
      

  2.   

    上面的朋友 rumlee ,我不清楚什么是jni,  可以提供一些有关 jni 的资料吗? 谢谢!!!
      

  3.   


    Java 关键字 native 怎样解理呢? 可以给示例代码解释一下吗?
      

  4.   

    看看JDK中的文档,以及安装目录下的src.zip,这是JDK的源代码,里面有很多地方使用到了JNI
      

  5.   

    java不适合做那种底层开发,如果实在想做,也只有用jni了,否则没戏
      

  6.   

    给一个简单例子:testdll.hpp:
    //-----------------------------------------------------------------
    /* DO NOT EDIT THIS FILE - it is machine generated */
    #include <jni.h>
    /* Header for class testdll */#ifndef _Included_testdll
    #define _Included_testdll
    #ifdef __cplusplus
    extern "C" {
    #endif
    /*
     * Class:     testdll
     * Method:    get
     * Signature: ()I
     */
    JNIEXPORT jint JNICALL Java_testdll_get
      (JNIEnv *, jclass);/*
     * Class:     testdll
     * Method:    set
     * Signature: (I)V
     */
    JNIEXPORT void JNICALL Java_testdll_set
      (JNIEnv *, jclass, jint);#ifdef __cplusplus
    }
    #endif
    #endif//----------------------------------------------------testdll.cpp:
    //-----------------------------------------------------
    #include "testdll.h" int i = 0; JNIEXPORT jint JNICALL Java_testdll_get (JNIEnv *, jclass) 

    return i; 
    } JNIEXPORT void JNICALL Java_testdll_set (JNIEnv *, jclass, jint j) 

    i = j; 

    //-----------------------------------------------------------------
    编成DLL后,在JAVA类中: static 

    System.loadLibrary("DLL名字"); 
    }     public native static int get();     public native static void set(int i);     public static void main(String[] args) 
        { 
    testdll test = new testdll(); 
    test.set(10); 
    System.out.println(test.get()); 
        }