SlideShare ist ein Scribd-Unternehmen logo
1 von 5
Downloaden Sie, um offline zu lesen
F -X C h a n ge                                                                                                                F -X C h a n ge
    PD                                                                                                                             PD




                         !




                                                                                                                                                        !
                        W




                                                                                                                                                       W
                       O




                                                                                                                                                      O
                     N




                                                                                                                                                    N
                   y




                                                                                                                                                  y
                bu




                                                                                                                                               bu
              to




                                                                                                                                             to
          k




                                                                                                                                         k
        lic




                                                                                                                                       lic
    C




                                                                                                                                   C
w




                                                                                                                               w
                                m




                                                                                                                                                               m
    w                                                                                                                              w
w




                                                                                                                               w
                               o




                                                                                                                                                              o
                               .c                                                                                                                             .c
                                                                                JNI
        .d o                                                                                                                           .d o
               c u -tr a c k                                                                                                                  c u -tr a c k




                                                      http://blog.chinaunix.net/u3/90973/index.html



                                          JNI


                                    JNI    Java Native Interface ,       Java                       java              jvm
                                                                                                             JAVA        JNI
                                                                                              WINDOWS               DLL
                                    UNIX               SO                                                              JAVA
                                                                                                       jvm




                                    Java Development Kit (JDK)             1.6.0
                                    Microsoft Visual Studio2005                          C                    dll

                                          JNI

                                    JNI    Java Native Interface ,       Java                       java            jvm
                                                                                                             JAVA      JNI
                                                                                              WINDOWS             DLL
                                    UNIX               SO                                                            JAVA
                                                                                                       jvm




                                    Java Development Kit (JDK)             1.6.0
                                    Microsoft Visual Studio2005                          C                    dll


                                                ·        native                  java
                                                ·   javac                       java
                                                ·   javah java                       h
                                                ·   C/C++
                                                ·                 java                       java
F -X C h a n ge                                                                                                  F -X C h a n ge
    PD                                                                                                               PD




                         !




                                                                                                                                          !
                        W




                                                                                                                                         W
                       O




                                                                                                                                        O
                     N




                                                                                                                                      N
                   y




                                                                                                                                    y
                bu




                                                                                                                                 bu
              to




                                                                                                                               to
          k




                                                                                                                           k
        lic




                                                                                                                         lic
    C




                                                                                                                     C
w




                                                                                                                 w
                                m




                                                                                                                                                 m
    w                                                                                                                w
w




                                                                                                                 w
                               o




                                                                                                                                                o
        .d o                   .c                                                                                        .d o                   .c
               c u -tr a c k                                                                                                    c u -tr a c k
                                    1        java
                                       JAVA
                                    static {
                                    System.loadLibrary(“dllname”);
                                    }

                                                                                   DLL     SO
                                                                    native
                                    public native static void fn1(int i);
                                    public native static int fn2(void );
                                                 JAVA                      CLASS           JAVAH   JNI   C/C++

                                                java        TestDel.java

                                    public class TestDel
                                    {
                                         static
                                         {
                                               System.loadLibrary("cjw"); //        cjw
                                         }

                                         public native static void creFolder();
                                         public native static void delFolder1();
                                         public native static void delFolder2();
                                         public static void main(String[] args)
                                         {
                                              TestDel test = new TestDel();

                                               System.out.println("start create Folder...");
                                               test.creFolder();
                                               System.out.println("create Folder finished.");

                                                long stime = System.currentTimeMillis();
                                               //test.delFolder1();
                                                  test.delFolder2();
                                             long etime =System.currentTimeMillis();

                                               System.out.println(etime-stime);
                                         }
                                    }
                                        javac TestDel.java                 TestDel.class
                                           javah TestDel                            TestDel.h            C/C++


                                    2
                                                       .h         C/C++

                                                           TestDel.h
                                    /* DO NOT EDIT THIS FILE - it is machine generated */
                                    #include <jni.h>
F -X C h a n ge                                                                                                       F -X C h a n ge
    PD                                                                                                                    PD




                         !




                                                                                                                                               !
                        W




                                                                                                                                              W
                       O




                                                                                                                                             O
                     N




                                                                                                                                           N
                   y




                                                                                                                                         y
                bu




                                                                                                                                      bu
              to




                                                                                                                                    to
          k




                                                                                                                                k
        lic




                                                                                                                              lic
    C




                                                                                                                          C
w




                                                                                                                      w
                                m




                                                                                                                                                      m
    w                                                                                                                     w
w




                                                                                                                      w
                               o




                                                                                                                                                     o
        .d o                   .c                                                                                             .d o                   .c
               c u -tr a c k                                                                                                         c u -tr a c k
                                    /* Header for class TestDel */
                                    #ifndef _Included_TestDel
                                    #define _Included_TestDel
                                    #ifdef __cplusplus
                                    extern "C" {
                                    #endif
                                    /*
                                    * Class:       TestDel
                                    * Method:       creFolder
                                    * Signature: ()V
                                    */
                                    JNIEXPORT void JNICALL Java_TestDel_creFolder
                                       (JNIEnv *, jclass);
                                    /*
                                    * Class:       TestDel
                                    * Method:       delFolder1
                                    * Signature: ()V
                                    */
                                    JNIEXPORT void JNICALL Java_TestDel_delFolder1
                                       (JNIEnv *, jclass);
                                    /*
                                    * Class:       TestDel
                                    * Method:       delFolder2
                                    * Signature: ()V
                                    */
                                    JNIEXPORT void JNICALL Java_TestDel_delFolder2
                                       (JNIEnv *, jclass);
                                    #ifdef __cplusplus
                                    }
                                    #endif
                                    #endif



                                    JNIEXPORT void JNICALL Java_TestDel_creFolder
                                       (JNIEnv *, jclass);
                                    JNIEXPORT void JNICALL Java_TestDel_delFolder1
                                       (JNIEnv *, jclass);
                                    JNIEXPORT void JNICALL Java_TestDel_delFolder2
                                       (JNIEnv *, jclass);
                                          JNIEXPORT        JNICALL    JNI                         JNI
                                    java                                  int                     jint         JNI
                                            JAVA int               int                                          int
                                                                     JAVA_      java      package
                                                                       JAVA                      JNIEnv*   jclass


                                                     dll

                                                     VS2005       dll           "WebDeploymentSetup.msi"    New
                                          VC++      win32 project       dll   Empty project java
F -X C h a n ge                                                                                                 F -X C h a n ge
    PD                                                                                                              PD




                         !




                                                                                                                                         !
                        W




                                                                                                                                        W
                       O




                                                                                                                                       O
                     N




                                                                                                                                     N
                   y




                                                                                                                                   y
                bu




                                                                                                                                bu
              to




                                                                                                                              to
          k




                                                                                                                          k
        lic




                                                                                                                        lic
    C




                                                                                                                    C
w




                                                                                                                w
                                m




                                                                                                                                                m
    w                                                                                                               w
w




                                                                                                                w
                               o




                                                                                                                                               o
        .d o                   .c                                                                                       .d o                   .c
               c u -tr a c k                                                                                                   c u -tr a c k
                                                                 test.cpp(       cpp           c      builder
                                      )test.cpp                   #include "TestDel.h"):

                                    #include <stdio.h>
                                    #include <direct.h>
                                    #include <stdlib.h>
                                    #include <stdio.h>
                                    #include <string.h>
                                    #include <sys/stat.h>
                                    #include "TestDel.h"

                                    JNIEXPORT void JNICALL Java_TestDel_creFolder(JNIEnv *, jclass)
                                    {
                                    int i,j;
                                    char buf1[20];
                                    char buf2[20]="./Folder/";
                                    char buf3[20];
                                    mkdir("Folder");
                                    for(i=0;i<100;i++)
                                    {
                                           itoa(i,buf1,10);
                                    mkdir(strcat(buf2,buf1));
                                    strcpy(buf3,strcat(buf2,""));
                                    for(j=0;j<100;j++)
                                    {
                                       itoa(j,buf1,10);
                                       mkdir(strcat(buf2,buf1));
                                       strcpy(buf2,buf3);
                                    }
                                    strcpy(buf2,"./Folder/");
                                    }
                                    }

                                    JNIEXPORT void JNICALL Java_TestDel_delFolder1
                                       (JNIEnv *, jclass)
                                    {
                                    int i,j;
                                    char buf1[20];
                                    char buf2[20]=".Folder";
                                    char buf3[20];
                                    for(i=0;i<100;i++)
                                    {
                                       itoa(i,buf1,10);
                                       strcat(buf1,"");
                                       strcpy(buf3,strcat(buf2,buf1));
                                       for(j=0;j<1000;j++)
                                       {
                                         itoa(j,buf1,10);
                                         rmdir(strcat(buf2,buf1));
                                         strcpy(buf2,buf3);
                                       }
                                       rmdir(buf3);
F -X C h a n ge                                                                                                                 F -X C h a n ge
    PD                                                                                                                              PD




                         !




                                                                                                                                                         !
                        W




                                                                                                                                                        W
                       O




                                                                                                                                                       O
                     N




                                                                                                                                                     N
                   y




                                                                                                                                                   y
                bu




                                                                                                                                                bu
              to




                                                                                                                                              to
          k




                                                                                                                                          k
        lic




                                                                                                                                        lic
    C




                                                                                                                                    C
w




                                                                                                                                w
                                m




                                                                                                                                                                m
    w                                                                                                                               w
w




                                                                                                                                w
                               o




                                                                                                                                                               o
        .d o                   .c                                                                                                       .d o                   .c
               c u -tr a c k                                                                                                                   c u -tr a c k
                                        strcpy(buf2,".Folder");
                                    }

                                    }
                                    JNIEXPORT void JNICALL Java_TestDel_delFolder2
                                      (JNIEnv *, jclass)
                                    {
                                      char    cmd[50];
                                      strcpy(cmd,"rmdir /s/q ");
                                      strcat(cmd,"Folder");
                                      system(cmd);

                                    }

                                                        SDK       include             (          win32                      )
                                                    VC    include                       VS toolsoptions -   Projects and
                                    SolutionsVC++ Project Settings          directories include
                                      ../sdk1.5.0/inlcude    ../sdk1.5.0/include/win32

                                                          dll( debug                              JAVA
                                                        cjw.dll

                                    3

                                        cjw.dll         TestDel.class          java TestDel

Weitere ähnliche Inhalte

Andere mochten auch

Proun snc | ufficio stampa / pubbliche relazioni / brand image |
Proun snc | ufficio stampa / pubbliche relazioni / brand image |Proun snc | ufficio stampa / pubbliche relazioni / brand image |
Proun snc | ufficio stampa / pubbliche relazioni / brand image |Proun snc
 
Once Upon A Time There Was Darwinism
Once Upon A Time There Was DarwinismOnce Upon A Time There Was Darwinism
Once Upon A Time There Was Darwinismakfaizal
 
GOTO - The Ultimate Android Lock Screen
GOTO - The Ultimate Android Lock ScreenGOTO - The Ultimate Android Lock Screen
GOTO - The Ultimate Android Lock ScreenInnoWeb Tech, LLC
 
Resolução cofeci n.º 32692
Resolução cofeci n.º 32692Resolução cofeci n.º 32692
Resolução cofeci n.º 32692Darcilio Santana
 
Proyecto de Biodiversidad primero
Proyecto de Biodiversidad primeroProyecto de Biodiversidad primero
Proyecto de Biodiversidad primeroNunca pierdas La Fe
 
Heterosis concepts
Heterosis conceptsHeterosis concepts
Heterosis conceptsdeepakigkv
 

Andere mochten auch (9)

Proun snc | ufficio stampa / pubbliche relazioni / brand image |
Proun snc | ufficio stampa / pubbliche relazioni / brand image |Proun snc | ufficio stampa / pubbliche relazioni / brand image |
Proun snc | ufficio stampa / pubbliche relazioni / brand image |
 
Once Upon A Time There Was Darwinism
Once Upon A Time There Was DarwinismOnce Upon A Time There Was Darwinism
Once Upon A Time There Was Darwinism
 
GOTO - The Ultimate Android Lock Screen
GOTO - The Ultimate Android Lock ScreenGOTO - The Ultimate Android Lock Screen
GOTO - The Ultimate Android Lock Screen
 
Estamentos
EstamentosEstamentos
Estamentos
 
Resolução cofeci n.º 32692
Resolução cofeci n.º 32692Resolução cofeci n.º 32692
Resolução cofeci n.º 32692
 
Retorikk ppp
Retorikk pppRetorikk ppp
Retorikk ppp
 
Proyecto de Biodiversidad primero
Proyecto de Biodiversidad primeroProyecto de Biodiversidad primero
Proyecto de Biodiversidad primero
 
Bleeding disorders
Bleeding disordersBleeding disorders
Bleeding disorders
 
Heterosis concepts
Heterosis conceptsHeterosis concepts
Heterosis concepts
 

Kürzlich hochgeladen

Unveiling the Intricacies of Leishmania donovani: Structure, Life Cycle, Path...
Unveiling the Intricacies of Leishmania donovani: Structure, Life Cycle, Path...Unveiling the Intricacies of Leishmania donovani: Structure, Life Cycle, Path...
Unveiling the Intricacies of Leishmania donovani: Structure, Life Cycle, Path...Dr. Asif Anas
 
3.26.24 Race, the Draft, and the Vietnam War.pptx
3.26.24 Race, the Draft, and the Vietnam War.pptx3.26.24 Race, the Draft, and the Vietnam War.pptx
3.26.24 Race, the Draft, and the Vietnam War.pptxmary850239
 
HED Office Sohayok Exam Question Solution 2023.pdf
HED Office Sohayok Exam Question Solution 2023.pdfHED Office Sohayok Exam Question Solution 2023.pdf
HED Office Sohayok Exam Question Solution 2023.pdfMohonDas
 
EBUS5423 Data Analytics and Reporting Bl
EBUS5423 Data Analytics and Reporting BlEBUS5423 Data Analytics and Reporting Bl
EBUS5423 Data Analytics and Reporting BlDr. Bruce A. Johnson
 
AUDIENCE THEORY -- FANDOM -- JENKINS.pptx
AUDIENCE THEORY -- FANDOM -- JENKINS.pptxAUDIENCE THEORY -- FANDOM -- JENKINS.pptx
AUDIENCE THEORY -- FANDOM -- JENKINS.pptxiammrhaywood
 
A gentle introduction to Artificial Intelligence
A gentle introduction to Artificial IntelligenceA gentle introduction to Artificial Intelligence
A gentle introduction to Artificial IntelligenceApostolos Syropoulos
 
The basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptxThe basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptxheathfieldcps1
 
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRA
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRADUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRA
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRATanmoy Mishra
 
Department of Health Compounder Question ‍Solution 2022.pdf
Department of Health Compounder Question ‍Solution 2022.pdfDepartment of Health Compounder Question ‍Solution 2022.pdf
Department of Health Compounder Question ‍Solution 2022.pdfMohonDas
 
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...Nguyen Thanh Tu Collection
 
What is the Future of QuickBooks DeskTop?
What is the Future of QuickBooks DeskTop?What is the Future of QuickBooks DeskTop?
What is the Future of QuickBooks DeskTop?TechSoup
 
The Stolen Bacillus by Herbert George Wells
The Stolen Bacillus by Herbert George WellsThe Stolen Bacillus by Herbert George Wells
The Stolen Bacillus by Herbert George WellsEugene Lysak
 
Quality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICEQuality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICESayali Powar
 
Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.EnglishCEIPdeSigeiro
 
10 Topics For MBA Project Report [HR].pdf
10 Topics For MBA Project Report [HR].pdf10 Topics For MBA Project Report [HR].pdf
10 Topics For MBA Project Report [HR].pdfJayanti Pande
 
CapTechU Doctoral Presentation -March 2024 slides.pptx
CapTechU Doctoral Presentation -March 2024 slides.pptxCapTechU Doctoral Presentation -March 2024 slides.pptx
CapTechU Doctoral Presentation -March 2024 slides.pptxCapitolTechU
 
Protein Structure - threading Protein modelling pptx
Protein Structure - threading Protein modelling pptxProtein Structure - threading Protein modelling pptx
Protein Structure - threading Protein modelling pptxvidhisharma994099
 
Over the counter (OTC)- Sale, rational use.pptx
Over the counter (OTC)- Sale, rational use.pptxOver the counter (OTC)- Sale, rational use.pptx
Over the counter (OTC)- Sale, rational use.pptxraviapr7
 

Kürzlich hochgeladen (20)

Unveiling the Intricacies of Leishmania donovani: Structure, Life Cycle, Path...
Unveiling the Intricacies of Leishmania donovani: Structure, Life Cycle, Path...Unveiling the Intricacies of Leishmania donovani: Structure, Life Cycle, Path...
Unveiling the Intricacies of Leishmania donovani: Structure, Life Cycle, Path...
 
3.26.24 Race, the Draft, and the Vietnam War.pptx
3.26.24 Race, the Draft, and the Vietnam War.pptx3.26.24 Race, the Draft, and the Vietnam War.pptx
3.26.24 Race, the Draft, and the Vietnam War.pptx
 
HED Office Sohayok Exam Question Solution 2023.pdf
HED Office Sohayok Exam Question Solution 2023.pdfHED Office Sohayok Exam Question Solution 2023.pdf
HED Office Sohayok Exam Question Solution 2023.pdf
 
EBUS5423 Data Analytics and Reporting Bl
EBUS5423 Data Analytics and Reporting BlEBUS5423 Data Analytics and Reporting Bl
EBUS5423 Data Analytics and Reporting Bl
 
Finals of Kant get Marx 2.0 : a general politics quiz
Finals of Kant get Marx 2.0 : a general politics quizFinals of Kant get Marx 2.0 : a general politics quiz
Finals of Kant get Marx 2.0 : a general politics quiz
 
AUDIENCE THEORY -- FANDOM -- JENKINS.pptx
AUDIENCE THEORY -- FANDOM -- JENKINS.pptxAUDIENCE THEORY -- FANDOM -- JENKINS.pptx
AUDIENCE THEORY -- FANDOM -- JENKINS.pptx
 
A gentle introduction to Artificial Intelligence
A gentle introduction to Artificial IntelligenceA gentle introduction to Artificial Intelligence
A gentle introduction to Artificial Intelligence
 
The basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptxThe basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptx
 
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRA
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRADUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRA
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRA
 
Department of Health Compounder Question ‍Solution 2022.pdf
Department of Health Compounder Question ‍Solution 2022.pdfDepartment of Health Compounder Question ‍Solution 2022.pdf
Department of Health Compounder Question ‍Solution 2022.pdf
 
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
 
March 2024 Directors Meeting, Division of Student Affairs and Academic Support
March 2024 Directors Meeting, Division of Student Affairs and Academic SupportMarch 2024 Directors Meeting, Division of Student Affairs and Academic Support
March 2024 Directors Meeting, Division of Student Affairs and Academic Support
 
What is the Future of QuickBooks DeskTop?
What is the Future of QuickBooks DeskTop?What is the Future of QuickBooks DeskTop?
What is the Future of QuickBooks DeskTop?
 
The Stolen Bacillus by Herbert George Wells
The Stolen Bacillus by Herbert George WellsThe Stolen Bacillus by Herbert George Wells
The Stolen Bacillus by Herbert George Wells
 
Quality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICEQuality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICE
 
Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.
 
10 Topics For MBA Project Report [HR].pdf
10 Topics For MBA Project Report [HR].pdf10 Topics For MBA Project Report [HR].pdf
10 Topics For MBA Project Report [HR].pdf
 
CapTechU Doctoral Presentation -March 2024 slides.pptx
CapTechU Doctoral Presentation -March 2024 slides.pptxCapTechU Doctoral Presentation -March 2024 slides.pptx
CapTechU Doctoral Presentation -March 2024 slides.pptx
 
Protein Structure - threading Protein modelling pptx
Protein Structure - threading Protein modelling pptxProtein Structure - threading Protein modelling pptx
Protein Structure - threading Protein modelling pptx
 
Over the counter (OTC)- Sale, rational use.pptx
Over the counter (OTC)- Sale, rational use.pptxOver the counter (OTC)- Sale, rational use.pptx
Over the counter (OTC)- Sale, rational use.pptx
 

Jni+简介与实现

  • 1. F -X C h a n ge F -X C h a n ge PD PD ! ! W W O O N N y y bu bu to to k k lic lic C C w w m m w w w w o o .c .c JNI .d o .d o c u -tr a c k c u -tr a c k http://blog.chinaunix.net/u3/90973/index.html JNI JNI Java Native Interface , Java java jvm JAVA JNI WINDOWS DLL UNIX SO JAVA jvm Java Development Kit (JDK) 1.6.0 Microsoft Visual Studio2005 C dll JNI JNI Java Native Interface , Java java jvm JAVA JNI WINDOWS DLL UNIX SO JAVA jvm Java Development Kit (JDK) 1.6.0 Microsoft Visual Studio2005 C dll · native java · javac java · javah java h · C/C++ · java java
  • 2. F -X C h a n ge F -X C h a n ge PD PD ! ! W W O O N N y y bu bu to to k k lic lic C C w w m m w w w w o o .d o .c .d o .c c u -tr a c k c u -tr a c k 1 java JAVA static { System.loadLibrary(“dllname”); } DLL SO native public native static void fn1(int i); public native static int fn2(void ); JAVA CLASS JAVAH JNI C/C++ java TestDel.java public class TestDel { static { System.loadLibrary("cjw"); // cjw } public native static void creFolder(); public native static void delFolder1(); public native static void delFolder2(); public static void main(String[] args) { TestDel test = new TestDel(); System.out.println("start create Folder..."); test.creFolder(); System.out.println("create Folder finished."); long stime = System.currentTimeMillis(); //test.delFolder1(); test.delFolder2(); long etime =System.currentTimeMillis(); System.out.println(etime-stime); } } javac TestDel.java TestDel.class javah TestDel TestDel.h C/C++ 2 .h C/C++ TestDel.h /* DO NOT EDIT THIS FILE - it is machine generated */ #include <jni.h>
  • 3. F -X C h a n ge F -X C h a n ge PD PD ! ! W W O O N N y y bu bu to to k k lic lic C C w w m m w w w w o o .d o .c .d o .c c u -tr a c k c u -tr a c k /* Header for class TestDel */ #ifndef _Included_TestDel #define _Included_TestDel #ifdef __cplusplus extern "C" { #endif /* * Class: TestDel * Method: creFolder * Signature: ()V */ JNIEXPORT void JNICALL Java_TestDel_creFolder (JNIEnv *, jclass); /* * Class: TestDel * Method: delFolder1 * Signature: ()V */ JNIEXPORT void JNICALL Java_TestDel_delFolder1 (JNIEnv *, jclass); /* * Class: TestDel * Method: delFolder2 * Signature: ()V */ JNIEXPORT void JNICALL Java_TestDel_delFolder2 (JNIEnv *, jclass); #ifdef __cplusplus } #endif #endif JNIEXPORT void JNICALL Java_TestDel_creFolder (JNIEnv *, jclass); JNIEXPORT void JNICALL Java_TestDel_delFolder1 (JNIEnv *, jclass); JNIEXPORT void JNICALL Java_TestDel_delFolder2 (JNIEnv *, jclass); JNIEXPORT JNICALL JNI JNI java int jint JNI JAVA int int int JAVA_ java package JAVA JNIEnv* jclass dll VS2005 dll "WebDeploymentSetup.msi" New VC++ win32 project dll Empty project java
  • 4. F -X C h a n ge F -X C h a n ge PD PD ! ! W W O O N N y y bu bu to to k k lic lic C C w w m m w w w w o o .d o .c .d o .c c u -tr a c k c u -tr a c k test.cpp( cpp c builder )test.cpp #include "TestDel.h"): #include <stdio.h> #include <direct.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include <sys/stat.h> #include "TestDel.h" JNIEXPORT void JNICALL Java_TestDel_creFolder(JNIEnv *, jclass) { int i,j; char buf1[20]; char buf2[20]="./Folder/"; char buf3[20]; mkdir("Folder"); for(i=0;i<100;i++) { itoa(i,buf1,10); mkdir(strcat(buf2,buf1)); strcpy(buf3,strcat(buf2,"")); for(j=0;j<100;j++) { itoa(j,buf1,10); mkdir(strcat(buf2,buf1)); strcpy(buf2,buf3); } strcpy(buf2,"./Folder/"); } } JNIEXPORT void JNICALL Java_TestDel_delFolder1 (JNIEnv *, jclass) { int i,j; char buf1[20]; char buf2[20]=".Folder"; char buf3[20]; for(i=0;i<100;i++) { itoa(i,buf1,10); strcat(buf1,""); strcpy(buf3,strcat(buf2,buf1)); for(j=0;j<1000;j++) { itoa(j,buf1,10); rmdir(strcat(buf2,buf1)); strcpy(buf2,buf3); } rmdir(buf3);
  • 5. F -X C h a n ge F -X C h a n ge PD PD ! ! W W O O N N y y bu bu to to k k lic lic C C w w m m w w w w o o .d o .c .d o .c c u -tr a c k c u -tr a c k strcpy(buf2,".Folder"); } } JNIEXPORT void JNICALL Java_TestDel_delFolder2 (JNIEnv *, jclass) { char cmd[50]; strcpy(cmd,"rmdir /s/q "); strcat(cmd,"Folder"); system(cmd); } SDK include ( win32 ) VC include VS toolsoptions - Projects and SolutionsVC++ Project Settings directories include ../sdk1.5.0/inlcude ../sdk1.5.0/include/win32 dll( debug JAVA cjw.dll 3 cjw.dll TestDel.class java TestDel