In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to deal with the interdependent dll of java calls. The content of the article is of high quality, so the editor shares it for you as a reference. I hope you will have some understanding of the relevant knowledge after reading this article.
I. description of the problem
Recently encountered when doing a function java need to call dll, and dll has a dependency, before is a separate call, in fact, the call to dll are template code, itself is not too difficult, mainly interdependent or encountered for the first time, hereby record and share to friends in need for reference.
II. Treatment methods
Among them, An is the entrance to the dll method, and A relies on the five dll of BMageCGravity, which inherits StdCallLibrary, compiles the template code that loads each dll, and all needs to be loaded in. Here, I rely on BpenceCgrad, which has six dll, so I have written six interfaces here to load different dll, mainly because StdCallLibrary does not support loading multiple dll. If you support it, you don't have to write more than one, and you don't have to talk about it and go straight to the code:
Class definition import com.sun.jna.Native;import com.sun.jna.win32.StdCallLibrary;/** ClassName: DllLoadClass * Function: TODO ADD FUNCTION. * Reason: TODO ADD REASON (optional). * date: 5:08:21 * * @ author on January 27th, 2022, the line will go to * @ version * / public class DllLoadClass {/ * * ClassName: a * Function: TODO to load A. * Reason: TODO ADD REASON (optional). * date: on January 27th, 2022, 5:08:58 * * @ author line will arrive at * @ version DllLoadClass * / public interface An extends StdCallLibrary {String dllName = "dllv2/A"; An INSTANCE = Native.load (dllName,A.class) Public String a (String inString);} / * ClassName: B * Function: TODO load B. * Reason: TODO ADD REASON (optional). * date: on January 27th, 2022, 5:09:27 * * @ author line will arrive at * @ version DllLoadClass * / public interface B extends StdCallLibrary {String dllName = "dllv2/B64"; B INSTANCE = Native.load (dllName,B.class) } / * * ClassName: C * Function: TODO load C. * Reason: TODO ADD REASON (optional). * date: on January 27th, 2022, 5:09:41 * * @ author line will arrive at * @ version DllLoadClass * / public interface C extends StdCallLibrary {String dllName = "dllv2/C64"; C INSTANCE = Native.load (dllName,C.class) } / * * ClassName: d * Function: TODO load D. * Reason: TODO ADD REASON (optional). * date: on January 27th, 2022, 5:09:50 * * @ author line will arrive at * @ version DllLoadClass * / public interface D extends StdCallLibrary {String dllName = "dllv2/D64"; D INSTANCE = Native.load (dllName,D.class) } / * * ClassName: e * Function: TODO load E. * Reason: TODO ADD REASON (optional). * date: on January 27th, 2022, 5:10:37 * * @ author line will arrive at * @ version DllLoadClass * / public interface E extends StdCallLibrary {String dllName = "dllv2/E64"; E INSTANCE = Native.load (dllName,E.class) } / * * ClassName: F * Function: TODO load F. * Reason: TODO ADD REASON (optional). * date: on January 27th, 2022, 5:10:01 * * @ author line will arrive at * @ version DllLoadClass * / public interface F extends StdCallLibrary {String dllName = "dllv2/F64"; F INSTANCE = Native.load (dllName,F.class) } / * * ClassName: G * Function: TODO load G. * Reason: TODO ADD REASON (optional). * date: on January 27th, 2022, at 5:10:10 * * @ author, the line will go to * @ version DllLoadClass * / public interface G extends StdCallLibrary {String dllName = "dllv2/G64"; G INSTANCE = Native.load (dllName,G.class);}} 2.2 call
Although the above is defined, how to call or use it? In fact, the call is also very simple, after all defined, in fact, we need to load all the dependencies, we are still directly on the code:
Public class Test {@ SuppressWarnings ("unused") public static void main (String [] args) {BB = DllLoadClass.B.INSTANCE; C c = DllLoadClass.C.INSTANCE; D d = DllLoadClass.D.INSTANCE; F f = DllLoadClass.F.INSTANCE; G g = DllLoadClass.G.INSTANCE AA = DllLoadClass.A.INSTANCE; String result = a.a ("");}}
The principle is to call the member variable and let it load in.
On the java call interdependent dll processing method is shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 228
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.