Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a Java library to access the native Windows API?

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

like image 420
flybywire Avatar asked Mar 03 '09 15:03

flybywire


People also ask

Can you use Windows API with Java?

You don't need to use JNI or the windows API directly as java is platform independent. I would suggest you try the standard libraries before considering JNI. I would also be interested to know if there are any free windows api's for java.

What is Java API library?

The Google API Client Library for Java provides functionality common to all Google APIs, for example HTTP transport, error handling, authentication, JSON parsing, media download/upload, and batching.

How do I get Windows API?

To call a Windows API using the DllImport attributeOpen a new Windows Application project by clicking New on the File menu, and then clicking Project. The New Project dialog box appears. Select Windows Application from the list of Visual Basic project templates. The new project is displayed.

Where are Windows API function stored?

Windows API functions are located inside Windows DLLs. The name of the . dll in which the requested function is located is usually identical to the Import Library section in the function's documentation.


6 Answers

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

http://jawinproject.sourceforge.net

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 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 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.

Also read up here:

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

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 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.

like image 74
GEOCHET Avatar answered Oct 06 '22 02:10

GEOCHET


JNA is pretty nice. I'm just a beginner and I found it very easy. Works not only for the Win32 API but for almost any other DLL.

like image 40
Jason S Avatar answered Oct 06 '22 03:10

Jason S


Jacob is quite good on the COM side (but it's real COM - like you write in C++ - if you are familiar with true COM programming, then Jacob is a snap to use)

like image 25
Kevin Day Avatar answered Oct 06 '22 04:10

Kevin Day


JNIWrapper or ConfyJ from from TeamDev.

like image 35
OscarRyz Avatar answered Oct 06 '22 03:10

OscarRyz


One more option is WinRun4J. It has a native binding layer that aims to be compatible with pinvoke.net (the native binding format used in dot net). See examples for more information. Its a little early days so YMMV.

(full disclosure: i work on the project).

Yet another option is JFFI - this is used in jruby and jython to interact with native libraries.

like image 29
Peter Smith Avatar answered Oct 06 '22 02:10

Peter Smith


Check out Waffle

like image 20
Mermeister Avatar answered Oct 06 '22 03:10

Mermeister