{"id":83,"date":"2008-06-08T23:39:39","date_gmt":"2008-06-08T14:39:39","guid":{"rendered":"http:\/\/www.typea.info\/blog\/index.php\/2008\/06\/08\/eclipsevisualstudiojni\/"},"modified":"2008-06-08T23:39:39","modified_gmt":"2008-06-08T14:39:39","slug":"eclipsevisualstudiojni","status":"publish","type":"post","link":"https:\/\/www.typea.info\/blog\/index.php\/2008\/06\/08\/eclipsevisualstudiojni\/","title":{"rendered":"Eclipse\u3068VisualStudio\u3092\u3064\u304b\u3063\u3066JNI\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4f5c\u308b\u624b\u9806"},"content":{"rendered":"<p>\u3061\u3087\u3063\u3068\u3001<a href=\"http:\/\/typea-mixi01.appspot.com\/yh_s?q=JNI\">JNI<\/a>\u3092\u4f7f\u3063\u3066\u3001Java\u7528\u306e\u30e6\u30fc\u30c6\u30a3\u30ea\u30c6\u30a3\u3092\u4f5c\u308d\u3046\u3068\u601d\u3063\u305f\u3089\u3001\u610f\u5916\u3068\u30c1\u30a7\u30c3\u30af\u30dd\u30a4\u30f3\u30c8\u304c\u591a\u304b\u3063\u305f\u306e\u3067\u3001\u30b5\u30f3\u30d7\u30eb\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4f5c\u308a\u3001\u624b\u9806\u3092\u30e1\u30e2\u3063\u3066\u304a\u304f\u3002<\/p>\n<h4><strong><font color=\"#0080ff\">\u984c\u6750<\/font><\/strong><\/h4>\n<p>\u984c\u6750\u306f\u4f55\u3067\u3082\u3088\u304b\u3063\u305f\u304c\u3001\u624b\u3054\u308d\u306a\u611f\u3058\u304c\u3059\u308b\u306e\u3067\u3001OS\u306e\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u3092\u8abf\u3079\u308bJNI\u7528DLL\u3092\u4f5c\u6210\u3059\u308b\u3002<\/p>\n<h4><strong><font color=\"#0080ff\">\u6982\u8981<\/font><\/strong><\/h4>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/09eb3a1ff7dd_12DDF\/uml01.jpg\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" border=\"0\" alt=\"uml01\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/09eb3a1ff7dd_12DDF\/uml01_thumb.jpg\" width=\"244\" height=\"148\" \/><\/a> <\/p>\n<p>MemoryChecker\u30af\u30e9\u30b9\u306f\u3001Java\u306e\u30a6\u30a3\u30f3\u30c9\u30a6\u3067\u3001TextArea\u306b\u30e1\u30e2\u30ea\u60c5\u5831\u3092\u51fa\u529b\u3059\u308b\u30e1\u30bd\u30c3\u30c9\u3092\u8ffd\u52a0\u3057\u305f\u3001MemoryListenerTextArea\u3092\u914d\u7f6e\u3002<\/p>\n<p>\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u3092\u8abf\u67fb\u3059\u308b\u62bd\u8c61\u30af\u30e9\u30b9\u3001AbsMemoryManager\u304b\u3089\u3001JVM\u306e\u30e1\u30e2\u30ea\u8abf\u67fb\u7528\u30af\u30e9\u30b9JavaMemoryManager\u3068\u3001OS\u306e\u30e1\u30e2\u30ea\u8abf\u67fb\u7528\u30af\u30e9\u30b9JNIMemoryManager\u3092\u6d3e\u751f\u3055\u305b\u308b\u3002<\/p>\n<p>\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u30c7\u30fc\u30bf\u4fdd\u6301\u7528\u306bMemoryStatus\u30af\u30e9\u30b9\u3092\u7528\u610f<\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/09eb3a1ff7dd_12DDF\/uml02.jpg\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" border=\"0\" alt=\"uml02\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/09eb3a1ff7dd_12DDF\/uml02_thumb.jpg\" width=\"219\" height=\"244\" \/><\/a> <\/p>\n<p>\u52d5\u304d\u3068\u3057\u3066\u306f\u3001MemoryChecker(\u30a6\u30a3\u30f3\u30c9\u30a6)\u304b\u3089\u3001JNIMemoryManager\u3092\u751f\u6210\u3059\u308b\u3002JNIMemoryManager\u306f\u3001DLL\u3092\u30ed\u30fc\u30c9\u3057\u3001MemoryStatus\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u6e21\u3059\u3002DLL\u3067\u306f\u3001\u30e1\u30e2\u30ea\u91cf\u3092\u6307\u5b9a\u30a4\u30f3\u30bf\u30fc\u30d0\u30eb\u6bce\u306b\u8abf\u67fb\u3057\u3066\u3001\u4fdd\u6301\u3059\u308bMemoryStatus\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306b\u30bb\u30c3\u30c8\u3057\u3001change\u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3076\u3002\u3053\u308c\u304c\u9806\u306b\u4f1d\u308f\u308a\u3001TextArea\u306b\u72b6\u6cc1\u3092\u8868\u793a\u3059\u308b\u3002<\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/09eb3a1ff7dd_12DDF\/win01.jpg\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" border=\"0\" alt=\"win01\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/09eb3a1ff7dd_12DDF\/win01_thumb.jpg\" width=\"244\" height=\"146\" \/><\/a> <\/p>\n<p>\u51fa\u6765\u4e0a\u304c\u308a\u306f\u3053\u3093\u306a\u611f\u3058\u3002<\/p>\n<h4><strong><font color=\"#0080ff\">\u4f5c\u6210\u624b\u9806\uff08Eclipse\u5074)<\/font><\/strong><\/h4>\n<p><strong>DLL\u547c\u3073\u51fa\u3057\u5143\u30af\u30e9\u30b9<\/strong><\/p>\n<ol>\n<li>DLL\u3092\u30ed\u30fc\u30c9\u3059\u308b\u8a18\u8ff0\u3092\u8ffd\u52a0 <\/li>\n<li>DLL\u306e\u95a2\u6570\u3092\u547c\u3073\u51fa\u3059\u30e1\u30bd\u30c3\u30c9\u3092native\u5ba3\u8a00 <\/li>\n<\/ol>\n<pre class=\"prettyprint linenums\">public class JNIMemoryManager extends AbsMemoryManager { \r\n  \/** DLL\u3092\u30ed\u30fc\u30c9 *\/ \r\n  static { \r\n    System.loadLibrary(&quot;MemStat&quot;); \r\n  }  \r\n  public JNIMemoryManager(IMemoryStatusListener listener, long inverval) { \r\n    super(listener, inverval); \r\n  } \r\n  public void changeStatus() { \r\n    this.listener.statusChenged(getMemoryStatus()); \r\n  } \r\n  \/** DLL\u304b\u3089MemoryStatus\u3092\u53d6\u5f97 *\/ \r\n  public native MemoryStatus getMemoryStatus(); \r\n  \/** DLL\u306bMemoryStatus\u3092\u30bb\u30c3\u30c8 *\/ \r\n  public native void setMemoryStatus(MemoryStatus memstat); \r\n  \/** DLL\u306e\u30e1\u30e2\u30ea\u8abf\u67fb\u3092\u958b\u59cb *\/ \r\n  public native void run(); \r\n  \/** DLL\u306e\u30e1\u30e2\u30ea\u8abf\u67fb\u3092\u7d42\u4e86 *\/ \r\n  public native void stop(); \r\n}<\/pre>\n<p>DLL\u6307\u5b9a\u306e\u62e1\u5f35\u5b50\u90e8\u5206\u3001dll\u3001so\u306f\u3001Java\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u304c\u52dd\u624b\u306b\u88dc\u5b8c\u3057\u3066\u304f\u308c\u308b\u306e\u3067\u4e0d\u8981\u3002<\/p>\n<p>\n  <br \/><strong>C\/C++ \u30d8\u30c3\u30c0\u30fc\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210<\/strong><\/p>\n<ol>\n<li>\u30b3\u30f3\u30d1\u30a4\u30eb\u6e08\u307fJava\u30af\u30e9\u30b9\u304b\u3089\u3001javah \u30b3\u30de\u30f3\u30c9\u3092\u5229\u7528\u3057\u3066\u3001C\/C++\u7528\u306e\u30d8\u30c3\u30c0\u30d5\u30a1\u30a4\u30eb\u3092\u751f\u6210 <\/li>\n<li>C\/C++\u3067\u306e\u51e6\u7406\u7528\u306b\u5229\u7528\u3059\u308bJava\u30af\u30e9\u30b9\u306e\u30b7\u30b0\u30cd\u30c1\u30e3\u3092javap\u30b3\u30de\u30f3\u30c9\u3092\u5229\u7528\u3057\u3066\u53d6\u5f97 <\/li>\n<\/ol>\n<p>\u4e0a\u8a18\u306e1.\u306f\u6700\u4f4e\u9650\u5fc5\u8981\u306a\u4f5c\u696d\u30022.\u306fDLL\u5074\u304b\u3089Java\u306e\u30af\u30e9\u30b9\u306e\u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3073\u51fa\u3059\u3068\u304d\u306b\u3001\u30e1\u30bd\u30c3\u30c9\u540d\u3068\u3001\u623b\u308a\u5024\u3001\u5f15\u6570\u306e\u30b7\u30b0\u30cd\u30c1\u30e3\u304c\u5fc5\u8981\u3060\u304c\u3001\u3053\u306e\u8a18\u8ff0\u304cJava\u3067\u306e\u901a\u5e38\u306e\u8a18\u8ff0\u3068\u306f\u3053\u3068\u306a\u308b\u306e\u3067\u3001\u7c21\u5358\u306b\u53d6\u5f97\u3059\u308b\u305f\u3081\u306b\u884c\u3046\u3002<\/p>\n<p>\u307e\u305f\u3001\u4e0a\u8a18\u4f5c\u696d\u3092\u3064\u3069\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u304b\u3089\u5b9f\u884c\u3059\u308b\u306e\u3082\u9762\u5012\u306a\u306e\u3067\u3001\u4ee5\u4e0b\u306e\u624b\u9806\u3067Ant\u306e\u30bf\u30b9\u30af\u3068\u3057\u3066\u767b\u9332\u3057\u3066\u304a\u304f\u3002<\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/09eb3a1ff7dd_12DDF\/eclipse01.jpg\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" border=\"0\" alt=\"eclipse01\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/09eb3a1ff7dd_12DDF\/eclipse01_thumb.jpg\" width=\"225\" height=\"135\" \/><\/a> <\/p>\n<p>\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u304b\u3089\u3001\u65b0\u898f\u4f5c\u6210-\u30d5\u30a1\u30a4\u30eb\u3067\u3001build.xml \u3068\u3044\u3046\u540d\u524d\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u8ffd\u52a0\u3057\u3001\u4ee5\u4e0b\u306e\u5185\u5bb9\u3092\u8a18\u8ff0\u3059\u308b\u3002<\/p>\n<pre class=\"prettyprint linenums\">&lt;project basedir=&quot;.\/&quot;&gt; \r\n  &lt;property name=&quot;cpdir&quot; value=&quot;${basedir}\\bin&quot;\/&gt; \r\n  &lt;target name=&quot;create c header file&quot;&gt; \r\n    &lt;!-- \r\n      JNI\u7528\u306eC\u30d8\u30c3\u30c0\u30fc\u30d5\u30a1\u30a4\u30eb\u3092\u751f\u6210 \r\n      -eg batch file \r\n         cd &quot;C:\\Program Files\\eclipse3.3.2\\workspace\\JNISample\\bin&quot; \r\n             javah -jni info.typea.jnisample.mem.JNIMemoryManager \r\n     --&gt; \r\n    &lt;exec executable=&quot;javah&quot;&gt; \r\n      &lt;arg value=&quot;-classpath&quot;\/&gt; \r\n      &lt;arg value=&quot;${cpdir}&quot;\/&gt; \r\n      &lt;arg value=&quot;-jni&quot;\/&gt; \r\n      &lt;arg value=&quot;info.typea.jnisample.mem.JNIMemoryManager&quot;\/&gt; \r\n    &lt;\/exec&gt; \r\n  &lt;\/target&gt; \r\n  &lt;target name=&quot;print signeture (MemoryStatus)&quot;&gt; \r\n    &lt;!-- \r\n      JNI\u7528\u30b7\u30b0\u30cd\u30c1\u30e3\u78ba\u8a8d(\u6a19\u6e96\u51fa\u529b\u306b\u51fa\u529b) \r\n      -eg batch file \r\n      cd &quot;C:\\Program Files\\eclipse3.3.2\\workspace\\JNISample\\bin&quot; \r\n      javap -private -s -classpath . info.typea.jnisample.mem.MemoryStatus \r\n    --&gt; \r\n    &lt;exec executable=&quot;javap&quot;&gt; \r\n      &lt;arg value=&quot;-private&quot;\/&gt; \r\n      &lt;arg value=&quot;-s&quot;\/&gt; \r\n      &lt;arg value=&quot;-classpath&quot;\/&gt;  \r\n      &lt;arg value=&quot;${cpdir}&quot;\/&gt; \r\n      &lt;arg value=&quot;info.typea.jnisample.mem.MemoryStatus&quot;\/&gt; \r\n    &lt;\/exec&gt; \r\n  &lt;\/target&gt; \r\n&lt;\/project&gt;<\/pre>\n<p>\u3042\u3068\u306f\u3001Eclipse\u306e\u30e1\u30cb\u30e5\u30fc- Window- Show View \u304b\u3089\u3001Ant\u3092\u958b\u304f\u3068\u3001\u4eca\u306e\u8a2d\u5b9a\u304c\u8868\u793a\u3055\u308c\u308b\u306e\u3067\u3001\u8a72\u5f53\u3092\u9078\u629e\u3057\u3066\u3001\u5b9f\u884c\u30dc\u30bf\u30f3\u3092\u62bc\u3059\u3068\u30d8\u30c3\u30c0\u30fc\u30d5\u30a1\u30a4\u30eb\u304c\u4f5c\u6210\u3055\u308c\u308b\u3002<\/p>\n<p>\u4eca\u56de\u306e\u4f8b\u3067\u306f\u3001\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u5c55\u958b\u3057\u305f\u3084\u305f\u3089\u9577\u3044\u540d\u524d\u306e\u30d8\u30c3\u30c0\u30fc\u30d5\u30a1\u30a4\u30eb\u304c\u4f5c\u6210\u3055\u308c\u308b\u3002<\/p>\n<p><strong>info_typea_jnisample_mem_JNIMemoryManager.h<\/strong><\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/09eb3a1ff7dd_12DDF\/eclipse02.jpg\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" border=\"0\" alt=\"eclipse02\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/09eb3a1ff7dd_12DDF\/eclipse02_thumb.jpg\" width=\"244\" height=\"68\" \/><\/a> <\/p>\n<p>\u3068\u308a\u3042\u3048\u305a\u3001\u3053\u3053\u307e\u3067\u3067Eclipse\u5074\u306f\u7d42\u4e86\u3002<\/p>\n<h4><strong><font color=\"#0080c0\">\u4f5c\u6210\u624b\u9806\uff08VisualStudio\u5074)<\/font><\/strong><\/h4>\n<p><strong>\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u4f5c\u6210<\/strong><\/p>\n<p>VisualStudio\u5074\u3067\u306f\u3001VC++\u3092\u5229\u7528\u3057\u3066\u3001<a href=\"http:\/\/typea-mixi01.appspot.com\/yh_s?q=MFC%E6%8B%A1%E5%BC%B5DLL\">MFC\u62e1\u5f35DLL<\/a>\u3092\u4f5c\u6210\u3059\u308b\u3002<\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/09eb3a1ff7dd_12DDF\/mfc01.jpg\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" border=\"0\" alt=\"mfc01\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/09eb3a1ff7dd_12DDF\/mfc01_thumb.jpg\" width=\"244\" height=\"134\" \/><\/a> <\/p>\n<p>\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u540d\u3092\u3001\u4e0a\u8a18Java\u5074\u3067\u30ed\u30fc\u30c9\u3059\u308bDLL\u306e\u540d\u79f0\u306b\u3059\u308b\u3002<\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/09eb3a1ff7dd_12DDF\/mfc02.jpg\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" border=\"0\" alt=\"mfc02\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/09eb3a1ff7dd_12DDF\/mfc02_thumb.jpg\" width=\"244\" height=\"149\" \/><\/a><\/p>\n<p>MFC\u62e1\u5f35DLL\u3092\u6307\u5b9a <\/p>\n<p><strong>JNI\u7528\u30d8\u30c3\u30c0\u30fc\u30d5\u30a1\u30a4\u30eb\u306e\u53d6\u308a\u8fbc\u307f<\/strong><\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/09eb3a1ff7dd_12DDF\/mfc03.jpg\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" border=\"0\" alt=\"mfc03\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/09eb3a1ff7dd_12DDF\/mfc03_thumb.jpg\" width=\"227\" height=\"106\" \/><\/a> <\/p>\n<p>\u5148\u307b\u3069\u4f5c\u6210\u3057\u305f\u300c<strong>info_typea_jnisample_mem_JNIMemoryManager.h<\/strong>\u300d\u3092\u3001\u4f5c\u6210\u3055\u308c\u305f\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u9069\u5f53\u306a\u3068\u3053\u308d\u306b\u30b3\u30d4\u30fc\u3057\u3066\u3001\u30bd\u30ea\u30e5\u30fc\u30b7\u30e7\u30f3\u30a8\u30af\u30b9\u30d7\u30ed\u30fc\u30e9\u306e\u30d8\u30c3\u30c0\u30fc\u30d5\u30a1\u30a4\u30eb\u306e\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u30e1\u30cb\u30e5\u30fc\u304b\u3089\u3001\u65e2\u5b58\u306e\u9805\u76ee\u3092\u9078\u3093\u3067\u53d6\u308a\u8fbc\u3080\u3002<\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/09eb3a1ff7dd_12DDF\/mfc04.jpg\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" border=\"0\" alt=\"mfc04\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/09eb3a1ff7dd_12DDF\/mfc04_thumb.jpg\" width=\"244\" height=\"127\" \/><\/a> <\/p>\n<p>\u5b9f\u88c5\u7528\u306b\u3001\u300c<strong>info_typea_jnisample_mem_JNIMemoryManager.cpp<\/strong>\u300d\u30d5\u30a1\u30a4\u30eb\u3092\u3001\u540c\u3058\u304f\u30bd\u30ea\u30e5\u30fc\u30b7\u30e7\u30f3\u30a8\u30af\u30b9\u30d7\u30ed\u30fc\u30e9\u306e\u30bd\u30fc\u30b9\u30d5\u30a1\u30a4\u30eb\u304b\u3089\u65b0\u3057\u3044\u9805\u76ee\u3068\u3057\u3066\u8ffd\u52a0\u3059\u308b\u3002<\/p>\n<p><strong>\u74b0\u5883\u8a2d\u5b9a<\/strong><\/p>\n<p>JNI\u7528\u306e\u30a4\u30f3\u30af\u30eb\u30fc\u30c9\u30d5\u30a1\u30a4\u30eb\u306e\u5834\u6240\u3092VisualStudio\u306b\u8a2d\u5b9a\u3059\u308b\u3002<\/p>\n<p>\u30e1\u30cb\u30e5\u30fc-\u30c4\u30fc\u30eb-\u30aa\u30d7\u30b7\u30e7\u30f3\u3067\u30aa\u30d7\u30b7\u30e7\u30f3\u30c0\u30a4\u30a2\u30ed\u30b0\u3092\u958b\u304d\u3001\u300c\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u304a\u3088\u3073\u30bd\u30ea\u30e5\u30fc\u30b7\u30e7\u30f3-VC++\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u300d\u3092\u9078\u629e\u3057\u3001\u300c\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u8868\u793a\u3059\u308b\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u300d\u306b\u3001\u300c\u30a4\u30f3\u30af\u30eb\u30fc\u30c9\u30d5\u30a1\u30a4\u30eb\u300d\u3092\u9078\u629e<\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/09eb3a1ff7dd_12DDF\/mfc05.jpg\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" border=\"0\" alt=\"mfc05\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/09eb3a1ff7dd_12DDF\/mfc05_thumb.jpg\" width=\"244\" height=\"116\" \/><\/a> <\/p>\n<p>\u3053\u3053\u306b\u3001JavaSDK\u306ejni.h\u3092\u542b\u3080\u3001include\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3001jni_md.h\u3092\u542b\u3080win32\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u6307\u5b9a\u3059\u308b\u3002<\/p>\n<p>\u3061\u306a\u307f\u306b\u3001\u4eca\u56de\u306e\u74b0\u5883\u3060\u3068\u3001<\/p>\n<ul>\n<li>C:\\Program Files\\Java\\jdk1.6.0_06\\include <\/li>\n<li>C:\\Program Files\\Java\\jdk1.6.0_06\\include\\win32 <\/li>\n<\/ul>\n<p>\u306e2\u3064\u3068\u306a\u308b\u3002<\/p>\n<p><strong>JVM\u5f15\u6570\u306e\u6307\u5b9a(Eclipse\u5074)<\/strong><\/p>\n<p>\u30c6\u30b9\u30c8\u6bb5\u968e\u3067\u306f\u3001\u30b3\u30f3\u30d1\u30a4\u30eb\u3055\u308c\u305fDLL\u3092Eclipse\u306e\u30c7\u30d0\u30c3\u30b0\u74b0\u5883\u304b\u3089\u8a8d\u8b58\u3055\u305b\u308b\u305f\u3081\u306b\u3001\u4ee5\u4e0b\u306e\u8a2d\u5b9a\u3092\u884c\u3046\u3002<\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/09eb3a1ff7dd_12DDF\/mfc06.jpg\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" border=\"0\" alt=\"mfc06\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/09eb3a1ff7dd_12DDF\/mfc06_thumb.jpg\" width=\"244\" height=\"196\" \/><\/a> <\/p>\n<p>\u5b9f\u884c\u3059\u308b\u30af\u30e9\u30b9\u306e\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u30e1\u30cb\u30e5\u30fc-Debug As-Open Debug Dialog\u3092\u9078\u629e\u3059\u308b\u3068\u3001\u4e0a\u8a18\u30c0\u30a4\u30a2\u30ed\u30b0\u304c\u8d77\u52d5\u3059\u308b\u306e\u3067\u3001Argument \u30bf\u30d6\u306e VM arguments\u306b\u3001-Djava.library.path \u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u6307\u5b9a\u3059\u308b\u3002\u5024\u306f\u3001DLL\u306e\u30d1\u30b9\u3002<\/p>\n<p>\u4eca\u56de\u306e\u4f8b\u3067\u306f\u3001<\/p>\n<p>-Djava.library.path=&quot;C:\\Documents and Settings\\Administrator\\My Documents\\Visual Studio 2005\\Projects\\MemStat\\Debug&quot;<\/p>\n<p>\u3068\u306a\u308b\u3002<\/p>\n<p>\u3053\u3053\u307e\u3067\u3067\u3001\u57fa\u672c\u7684\u306a\u8a2d\u5b9a\u306f\u5b8c\u4e86\u306a\u306e\u3067\u3001\u5f8c\u306f\u3001\u5b9f\u88c5\u3092\u884c\u3046\u3002<\/p>\n<h4><strong><font color=\"#0080ff\">DLL\u306e\u5b9f\u88c5<\/font><\/strong><\/h4>\n<p>JNI\u306e\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9\u306f\u3001<a href=\"http:\/\/java.sun.com\/javase\/ja\/6\/docs\/ja\/technotes\/guides\/jni\/spec\/jniTOC.html\">\u3053\u3053<\/a>\u3089\u3042\u305f\u308a\u306b\u3001\u3042\u308b\u306e\u3067\u7d50\u5c40\u306f\u305d\u3053\u3092\u8aad\u3081\u3070\u3088\u3044\u306e\u3060\u304c\u3001\u3044\u304b\u3093\u305b\u3093\u306a\u3058\u307f\u304c\u306a\u3044\u306e\u3067\u3001\u7d20\u76f4\u306b\u306f\u8aad\u307f\u9032\u3081\u3089\u308c\u306a\u304b\u3063\u305f\u3002<\/p>\n<p>\u4e0a\u8a18\u30b7\u30ca\u30ea\u30aa\u306b\u57fa\u3065\u3044\u3066\u3001\u4f5c\u6210\u3057\u305f\u30b3\u30fc\u30c9\u306b\u88dc\u8db3\u3059\u308b\u3002<\/p>\n<pre class=\"prettyprint linenums\">#include &quot;stdafx.h&quot;\r\n#include &quot;info_typea_jnisample_mem_JNIMemoryManager.h&quot;\r\n\r\njobject global_memstat; \/\/ (2)\r\nboolean _stopFlag;\r\n\r\n\/*\r\n* Class:     info_typea_jnisample_mem_JNIMemoryManager\r\n* Method:    getMemoryStatus\r\n* Signature: ()Linfo\/typea\/jnisample\/mem\/MemoryStatus;\r\n*\/\r\nJNIEXPORT jobject JNICALL Java_info_typea_jnisample_mem_JNIMemoryManager_getMemoryStatus\r\n  (JNIEnv *env, jobject thisObj){ \/\/ (1)\r\n  return global_memstat;\r\n}\r\n\r\n\/*\r\n* Class:     info_typea_jnisample_mem_JNIMemoryManager\r\n* Method:    setMemoryStatus\r\n* Signature: (Linfo\/typea\/jnisample\/mem\/MemoryStatus;)V\r\n*\/\r\nJNIEXPORT void JNICALL Java_info_typea_jnisample_mem_JNIMemoryManager_setMemoryStatus\r\n  (JNIEnv *env, jobject thisObj, jobject memstat) {\r\n\r\n  global_memstat = env-&gt;NewGlobalRef(memstat); \/\/ (2-1)\r\n}\r\n\r\n\/*\r\n* Class:     info_typea_jnisample_mem_JNIMemoryManager\r\n* Method:    start\r\n* Signature: ()V\r\n*\/\r\nJNIEXPORT void JNICALL Java_info_typea_jnisample_mem_JNIMemoryManager_run\r\n  (JNIEnv *env, jobject thisObj){\r\n\r\n  \/\/ (3)\r\n  jclass mng = env-&gt;GetObjectClass(thisObj);\r\n  jmethodID jmIntvl = env-&gt;GetMethodID(mng, &quot;getInterval&quot;, &quot;()J&quot;);\r\n  jlong interval = env-&gt;CallLongMethod(thisObj, jmIntvl);\r\n\r\n  _stopFlag = false;\r\n\r\n  jclass jc = env-&gt;GetObjectClass(global_memstat);\r\n  jmethodID jmChng  = env-&gt;GetMethodID(jc, &quot;change&quot;, &quot;()V&quot;);\r\n\r\n  jmethodID jmMemLd\r\n    = env-&gt;GetMethodID(jc, &quot;setMemoryLoad&quot;,    &quot;(I)V&quot;);\r\n  jmethodID jmTtlPs\r\n    = env-&gt;GetMethodID(jc, &quot;setTotalPhys&quot;,     &quot;(I)V&quot;);\r\n  jmethodID jmAvlPs\r\n    = env-&gt;GetMethodID(jc, &quot;setAvailPhys&quot;,     &quot;(I)V&quot;);\r\n  jmethodID jmTtlPf\r\n    = env-&gt;GetMethodID(jc, &quot;setTotalPageFile&quot;, &quot;(I)V&quot;);\r\n  jmethodID jmAvlPf\r\n    = env-&gt;GetMethodID(jc, &quot;setAvailPageFile&quot;, &quot;(I)V&quot;);\r\n  jmethodID jmTtlVr\r\n    = env-&gt;GetMethodID(jc, &quot;setTotalVirtual&quot;,  &quot;(I)V&quot;);\r\n  jmethodID jmAvlVr\r\n    = env-&gt;GetMethodID(jc, &quot;setAvailVirtual&quot;,  &quot;(I)V&quot;);\r\n\r\n  MEMORYSTATUS memstat;\r\n\r\n  while (!_stopFlag) {\r\n    GlobalMemoryStatus( &amp;memstat );\r\n\r\n    env-&gt;CallVoidMethod\r\n      (global_memstat, jmMemLd, memstat.dwMemoryLoad);\r\n    env-&gt;CallVoidMethod\r\n      (global_memstat, jmTtlPs, memstat.dwTotalPhys  \/ 1024);\r\n    env-&gt;CallVoidMethod\r\n      (global_memstat, jmAvlPs, memstat.dwAvailPhys  \/ 1024);\r\n    env-&gt;CallVoidMethod\r\n      (global_memstat, jmTtlPf, memstat.dwTotalPageFile \/ 1024);\r\n    env-&gt;CallVoidMethod\r\n      (global_memstat, jmAvlPf, memstat.dwAvailPageFile \/ 1024);\r\n    env-&gt;CallVoidMethod\r\n      (global_memstat, jmTtlVr, memstat.dwTotalVirtual  \/ 1024);\r\n    env-&gt;CallVoidMethod\r\n      (global_memstat, jmAvlVr, memstat.dwAvailVirtual  \/ 1024);\r\n    env-&gt;CallVoidMethod(global_memstat, jmChng);\r\n\r\n    SleepEx(interval, FALSE);\r\n  }\r\n}\r\n\r\n\/*\r\n* Class:     info_typea_jnisample_mem_JNIMemoryManager\r\n* Method:    stop\r\n* Signature: ()V\r\n*\/\r\nJNIEXPORT void JNICALL Java_info_typea_jnisample_mem_JNIMemoryManager_stop\r\n(JNIEnv *env, jobject thisObj) {\r\n  _stopFlag = true;\r\n\r\n  env-&gt;DeleteGlobalRef(global_memstat); \/\/ (2-1)\r\n\r\n  global_memstat = NULL;\r\n}<\/pre>\n<p>&#160;<\/p>\n<p><strong>(1) \u95a2\u6570\u5ba3\u8a00<\/strong><\/p>\n<p>1\u3064\u76ee\u306e\u5f15\u6570\u306b\u3001JNIEnv\u3068\u3057\u3066\u3001JNI\u7528\u306e\u95a2\u6570\u30c6\u30fc\u30d6\u30eb\u304c\u6e21\u3055\u308c\u308b\u3002\u3053\u308c\u3092\u5229\u7528\u3057\u3066\u5404\u7a2e\u64cd\u4f5c\u3092\u884c\u3046\u3002<\/p>\n<p>2\u3064\u76ee\u306e\u5f15\u6570\u306b\u306f\u3001\u547c\u3073\u51fa\u3057\u5143\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304c\u6e21\u3055\u308c\u308b\u3002<\/p>\n<p><strong>(2) \u30b0\u30ed\u30fc\u30d0\u30eb\u53c2\u7167<\/strong><\/p>\n<p>DLL\u306e\u95a2\u6570\u3092\u307e\u305f\u304c\u3063\u3066\u3001Java\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u4fdd\u6301\u3057\u305f\u3044\u5834\u5408\u3001(2)\u306e\u3088\u3046\u306b\u5ba3\u8a00\u3057\u3066\u3001\u521d\u56de\u306e\u95a2\u6570\u547c\u3073\u51fa\u3057\u6642\u306e\u5f15\u6570jobject\u3092\u4ee3\u5165\u3057\u3066\u304a\u304f\u3060\u3051\u3067\u306f\u3001\u6b21\u56de\u306e\u95a2\u6570\u547c\u3073\u51fa\u3057\u6642\u306b\u3001\u305d\u306e\u5024\u306f\u5229\u7528\u3067\u304d\u306a\u3044\u3002\u305d\u306e\u3088\u3046\u306a\u5834\u5408\u3001\u30b0\u30ed\u30fc\u30d0\u30eb\u53c2\u7167\u3092\u5229\u7528\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u3001\u4f5c\u6210\u6642\u306b\u306f\u3001<\/p>\n<p>NewGlobalRef<\/p>\n<p>\u7834\u68c4\u6642\u306b\u306f\u3001<\/p>\n<p>DeleteGlobalRef<\/p>\n<p>\u3092\u4f7f\u7528\u3059\u308b\u3002<\/p>\n<p><strong>(3) Java\u30e1\u30bd\u30c3\u30c9\u306e\u547c\u3073\u51fa\u3057<\/strong><\/p>\n<p>1:&#160; JNIEXPORT void JNICALL Java_info_typea_jnisample_mem_JNIMemoryManager_run <\/p>\n<p>&#160;&#160;&#160; (JNIEnv *env, jobject thisObj){ <\/p>\n<p>2:&#160; jclass mng = env-&gt;GetObjectClass(thisObj);<br \/>\n  <br \/>3:&#160; jmethodID jmIntvl = env-&gt;GetMethodID(mng, &quot;getInterval&quot;, &quot;()J&quot;); <\/p>\n<p>4:&#160; jlong interval = env-&gt;CallLongMethod(thisObj, jmIntvl); <\/p>\n<p>\u4eca\u56de\u306e\u4f8b\u3067\u3001native\u30e1\u30bd\u30c3\u30c9\u547c\u3073\u51fa\u3057\u5143\u3067\u3042\u308b\u3001JNIMemoryManager\u30af\u30e9\u30b9\u306egetInterval\u30e1\u30bd\u30c3\u30c9\u3092\u3001JNI\u95a2\u6570\u306e\u4e2d\u304b\u3089\u547c\u3073\u51fa\u3059\u5834\u5408\u3001<\/p>\n<p>1\u884c\u76ee:JNIMemoryManager\u306enative\u30e1\u30bd\u30c3\u30c9run\u304c\u547c\u3073\u51fa\u3055\u308c\u308b\u30022\u3064\u76ee\u306e\u5f15\u6570\u306b\u3001JNIMemoryManager\u81ea\u8eab\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304c\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u308b\u3002<\/p>\n<p>2\u884c\u76ee:JNIMemoryManager\u81ea\u8eab\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304b\u3089\u3001GetObjectClass\u95a2\u6570\u3092\u5229\u7528\u3057\u3066\u3001jclass\u3092\u53d6\u5f97\u3059\u308b\u3002<\/p>\n<p>3\u884c\u76ee:\u53d6\u5f97\u3057\u305f\u3001jclass\u306b\u3001\u30e1\u30bd\u30c3\u30c9\u540d\u3001\u30b7\u30b0\u30cd\u30c1\u30e3\u3092\u6307\u5b9a(\u3053\u3053\u3067\u3001\u4e0a\u8a18\u3067\u4f5c\u6210\u3057\u305f\u3001Ant\u30bf\u30b9\u30af\u3092\u5229\u7528\u3059\u308b\u3068\u4fbf\u5229 \u3061\u306a\u307f\u306b\u3001()J\u306f\u3001\u5f15\u6570\u306a\u3057\u3001\u623b\u308a\u5024long)\u3057\u3066GetMethodID\u3092\u547c\u3073\u51fa\u3059\u3068\u3001jmethodID\u3092\u53d6\u5f97\u3067\u304d\u308b\u3002<\/p>\n<p>4:\u623b\u308a\u5024\u306b\u3042\u308f\u305b\u305fCallxxxMethod\u95a2\u6570\u3092\u5229\u7528\u3057\u3066\u3001\u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3073\u51fa\u3059\u3002<\/p>\n<p>&#160;<\/p>\n<p>\u3068\u3002\u3068\u308a\u3042\u3048\u305a\u306f\u3053\u3093\u306a\u3068\u3053\u308d\u3002<\/p>\n<p>\u307e\u3041\u3042\u3068\u306f\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9\u3092\u898b\u306a\u304c\u3089\u4f55\u3068\u304b\u306a\u308b\u304b\u306a\u3002<\/p>\n<p>\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306f<a href=\"\/tips\/wiki.cgi?page=JNI%A5%B5%A5%F3%A5%D7%A5%EB\">\u3053\u3053<\/a>\u3002<\/p>\n<div class=\"amazon\"><a href=\"http:\/\/www.amazon.co.jp\/exec\/obidos\/ASIN\/4274079031\/typea09-22\"><img decoding=\"async\" src=\"http:\/\/images-jp.amazon.com\/images\/P\/4274079031.09.MZZZZZZZ.jpg\" \/><\/a><\/div>\n<div class=\"amazon\"><font color=\"#8080ff\" size=\"1\">\u3061\u3087\u3063\u3068\u53e4\u3044\u672c\u3060\u3051\u3069\u3001JNI\u306b\u3064\u3044\u3066\u3001\u4e01\u5be7\u306b\u8aac\u660e\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/font><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u3061\u3087\u3063\u3068\u3001JNI\u3092\u4f7f\u3063\u3066\u3001Java\u7528\u306e\u30e6\u30fc\u30c6\u30a3\u30ea\u30c6\u30a3\u3092\u4f5c\u308d\u3046\u3068\u601d\u3063\u305f\u3089\u3001\u610f\u5916\u3068\u30c1\u30a7\u30c3\u30af\u30dd\u30a4\u30f3\u30c8\u304c\u591a\u304b\u3063\u305f\u306e\u3067\u3001\u30b5\u30f3\u30d7\u30eb\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4f5c\u308a\u3001\u624b\u9806\u3092\u30e1\u30e2\u3063\u3066\u304a\u304f\u3002 \u984c\u6750 \u984c\u6750\u306f\u4f55\u3067\u3082\u3088\u304b\u3063\u305f\u304c\u3001\u624b\u3054\u308d\u306a\u611f\u3058\u304c\u3059\u308b\u306e\u3067\u3001OS\u306e\u30e1 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"sns_share_botton_hide":"","vkExUnit_sns_title":"","_vk_print_noindex":"","sitemap_hide":"","_veu_custom_css":"","veu_display_promotion_alert":"","vkexunit_cta_each_option":"","footnotes":""},"categories":[16,6,17,12],"tags":[],"class_list":["post-83","post","type-post","status-publish","format-standard","hentry","category-eclipse","category-java","category-vc","category-visualstudio"],"veu_head_title_object":{"title":"","add_site_title":""},"_links":{"self":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts\/83","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=83"}],"version-history":[{"count":0,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts\/83\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=83"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=83"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=83"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}