Configure Java JNI dynamic library development in VC6.0

Source: Internet
Author: User

JAVA is a software development language running on virtual machines. It relies on virtual machines to explain bytecode, cleverly implementing cross-platform. JAVA is relatively secure because it is closed. However, external calls are implemented through the JNI dynamic library. Today, we will explain how to develop a JNI dynamic library for vc6.0 configuration.

1, need to download resources 1, jdk-7u45-windows-i586 2, vc6.0.

2. Compile a java Helloworld class

Public class HelloWorld {public native void displayHelloWorld (); // declare static {System. loadLibrary ("HelloWorldImpl"); // load the dynamic link library. "HelloWorldImpl" is the name of the dynamic link library to be loaded .} Public static void main (String [] args) {// TODO Auto-generated method stubHelloWorld helloWorld = new HelloWorld (); helloWorld. displayHelloWorld ();}}

3. Export HelloWorld. h

d:\JNI>javac HelloWorld.java

The exported content is as follows:

/* DO NOT EDIT THIS FILE - it is machine generated */#include 
 
  /* Header for class HelloWorld */#ifndef _Included_HelloWorld#define _Included_HelloWorld#ifdef __cplusplusextern "C" {#endif/* * Class:     HelloWorld * Method:    displayHelloWorld * Signature: ()V */JNIEXPORT void JNICALL Java_HelloWorld_displayHelloWorld  (JNIEnv *, jobject);#ifdef __cplusplus}#endif#endif
 

4. Use the vc6.0 win32dll project to add the header file and write the local implementation file

#include "HelloWord.h"#include 
 
  #include 
  
   /* * Class:     HelloWorld * Method:    displayHelloWorld * Signature: ()V */JNIEXPORT void JNICALL Java_HelloWorld_displayHelloWorld  (JNIEnv *, jobject) {    printf("Hello World!\n");    return;}
  
 

5. Configure the header file of vc6.0 to include directories and library files. And pin the newly added Path to the top.



Last step compilation



Successful.

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.