Java calls the methods in the DLL file

Source: Internet
Author: User

First, write a class in Java, which contains the methods to implement the functions. These methods are declared as native, and then generate the. h header file using javah, and then write it using JNI.ProgramCall the existing DLL and use the C or C ++ compiler to compile your JNI implementation.

First, you must learn how to write a JNI program, and then learn how to call an external DLL in C or C ++. This is a loadliberary process.

 

The most troublesome thing is to put the DLL files in a directory so that Java programs can find them. I don't know where to put them correctly, if it is not clear, it can be used everywhere in java_home, program files/Java, system32, and program directories. It is said that the dll path should be specified by Java. Library. Path. Otherwise, it should be loaded according to the system library path.

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.