JNI -- Java calls C/C ++ Functions

Source: Internet
Author: User

I. IntroductionIi. Purpose: Calling C/C ++ code in Java code 3. Implementation: Assume that our Java program is J2C. java, the C program is J2C. c, and the communication function between Java and C is called write2proc. 4. Operation






V. Specific Process

1.Compile and compile J2C. java

                                                         System.loadLibrary("j2c"           }                  System.err.println( "Cannot load J2C library:\n " +                     write2proc(                                 RuntimeMXBean runtime =            String info =             index = info.indexOf("@"              (index != -1                  pid = Integer.parseInt(info.substring(0                                  Thread.sleep(8000           }     }

 

,

  #include <jni.h>     _Included_J2C                 (JNIEnv *     

 

 #include <stdio.h>  #include   JNIEXPORT  JNICALL Java_J2C_write2proc(JNIEnv *        printf(          }

 

2. "error: request for member 'getstringutfchars' in something not a structure or union" encountered during JNI Development"









How to resolve java. lang. UnsatisfiedLinkError 



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.