是否有Java库来访问本机Windows API? [英] Is there a Java library to access the native Windows API?

查看:298
本文介绍了是否有Java库来访问本机Windows API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有Java库可以访问本机Windows API?使用COM或JNI。

Is there a Java library to access the native Windows API? Either with COM or JNI.

推荐答案

你可以试试这两个,我看到两者都取得了成功。

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

http://jawinproject.sourceforge.net


Java / Win32集成项目
(Jawin)是一个免费的开源
架构,用于Java和暴露的组件之间的互操作

通过Microsoft的组件对象
模型(COM)或通过Win32 Dynamic
链接库(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程序提供了对原生共享库(
Windows上的DLL)的轻松访问
,而无需编写任何东西,只需
Java代码 - 否JNI或本机代码需要
。这个功能是
,与Windows的Platform / Invoke
和Python的ctypes相当。在没有代码生成的情况下,Access是动态

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 Native Interface(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
Native接口的
库。 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.

这篇关于是否有Java库来访问本机Windows API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆