日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
Java訪問C++方法JavaCPP

JavaCPP提供了在Java中高效訪問本地C++的方法。采用JNI技術(shù)實(shí)現(xiàn),支持所有Java實(shí)現(xiàn)包括Android系統(tǒng),Avian 和 RoboVM。

JavaCPP提供了一系列的Annotation將Java代碼映射到C++代碼,并使用一個可執(zhí)行的jar包將C++代碼轉(zhuǎn)化為可以從JVM內(nèi)調(diào)用的動態(tài)鏈接庫文件。

Maven:

 
 
  1.     org.bytedeco
  2.     javacpp
  3.     0.11

使用方法:

C++:

 
 
  1. #include 
  2.  
  3. namespace LegacyLibrary {
  4.     class LegacyClass {
  5.         public:
  6.             const std::string& get_property() { return property; }
  7.             void set_property(const std::string& property) { this->property = property; }
  8.             std::string property;
  9.     };
  10. }

Java:

 
 
  1. import org.bytedeco.javacpp.*;
  2. import org.bytedeco.javacpp.annotation.*;
  3.  
  4. @Platform(include="LegacyLibrary.h")
  5. @Namespace("LegacyLibrary")
  6. public class LegacyLibrary {
  7.     public static class LegacyClass extends Pointer {
  8.         static { Loader.load(); }
  9.         public LegacyClass() { allocate(); }
  10.         private native void allocate();
  11.  
  12.         // to call the getter and setter functions 
  13.         public native @StdString String get_property(); public native void set_property(String property);
  14.  
  15.         // to access the member variable directly
  16.         public native @StdString String property();     public native void property(String property);
  17.     }
  18.  
  19.     public static void main(String[] args) {
  20.         // Pointer objects allocated in Java get deallocated once they become unreachable,
  21.         // but C++ destructors can still be called in a timely fashion with Pointer.deallocate()
  22.         LegacyClass l = new LegacyClass();
  23.         l.set_property("Hello World!");
  24.         System.out.println(l.property());
  25.     }
  26. }

分享文章:Java訪問C++方法JavaCPP
標(biāo)題鏈接:http://www.5511xx.com/article/cdhiiej.html