且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

是否有用于访问本机 Windows API 的 Java 库?

更新时间:2023-01-25 17:26:03

你可以试试这两个,我已经看到两者都成功了.

You could try these two, I have seen success with both.

http://jawinproject.sourceforge.net

Java/Win32 集成项目(Jawin) 是一个免费、开源的互操作架构在 Java 和暴露的组件之间通过微软的组件对象模型 (COM) 或通过 Win32 动态链接库 (DLL).

The Java/Win32 integration project (Jawin) is a free, open source architecture for interoperation between Java and components exposed through Microsoft's Component Object Model (COM) or through Win32 Dynamic Link Libraries (DLLs).

https://github.com/twall/jna/

JNA 为 Java 程序提供方便的访问到本机共享库(DLL 上的Windows) 不写任何东西,但Java 代码——没有 JNI 或本机代码必需的.这个功能是可与 Windows 的平台/调用相媲美和 Python 的 ctypes.访问是动态的在运行时无需生成代码.

JNA provides Java programs easy access to native shared libraries (DLLs on Windows) without writing anything but Java code—no JNI or native code is required. This functionality is comparable to Windows' Platform/Invoke and Python's ctypes. Access is dynamic at runtime without code generation.

JNA 允许您直接调用使用自然 Java 的本机函数方法调用.Java 调用看起来就像它在本机代码中所做的那样.最多呼叫不需要特殊处理或配置;没有样板或生成的代码是必需的.

JNA allows you to call directly into native functions using natural Java method invocation. The Java call looks just like it does in native code. Most calls require no special handling or configuration; no boilerplate or generated code is required.

另请阅读此处:

http://en.wikipedia.org/wiki/Java_Native_Interface

Java 本机接口 (JNI) 是一个允许Java的编程框架在 Java 虚拟机中运行的代码(JVM) 调用和被调用1本机应用程序(特定于程序的到硬件和操作系统平台)和库其他语言,如 C、C++ 和组装.

The Java Native Interface (JNI) is a programming framework that allows Java code running in a Java Virtual Machine (JVM) to call and to be called1 by native applications (programs specific to a hardware and operating system platform) and libraries written in other languages, such as C, C++ and assembly.

http://en.wikipedia.org/wiki/Java_Native_Access

Java Native Access 提供 Java程序轻松访问本机共享不使用 Java 的库本机接口.JNA 的设计旨在以自然的方式提供本地访问以最少的努力.不样板或生成的胶水代码是需要.

Java Native Access provides Java programs easy access to native shared libraries without using the Java Native Interface. JNA's design aims to provide native access in a natural way with a minimum of effort. No boilerplate or generated glue code is required.