NativeCall
Call native methods from Java without JNI
NativeCall lets you call native methods from Java without JNI
code. The current version 0.4.1 supports struct
s, Strings, primitive
types (int
and boolean
), byte
and char
arrays and output parameters. NativeCall is implemented for the Windows platform.
With NativeCall, you can call all methods implemented in any DLL.
Download
Quick start
- Download NativeCall.
- Extract
nativecall-0.4.1.jar
andnativeloader-200505172341.jar
. - Make sure both JAR files are in your classpath.
- Extract the native library (
NativeCall.dll
). - Read the Apidocs.
- Try the examples below.
Example code
Copying a file to a new one using the Windows API
import com.eaio.nativecall.*; NativeCall.init(); IntCall ic = new IntCall("CopyFileA"); ic.executeCall(new Object[] { "test.txt", "test_copy.txt", Boolean.FALSE }); ic.destroy();
Setting a file’s attributes to be hidden
import com.eaio.nativecall.*; NativeCall.init(); IntCall setFileAttributesA = new IntCall("SetFileAttributesA"); boolean success = setFileAttributesA.executeBooleanCall(new Object[] "documents/test.txt", new Integer(2) }); setFileAttributesA.destroy();
Working with structs to create a file, obtain the file handle and close the handle
import java.io.*; import com.eaio.nativecall.*; NativeCall.init(); IntCall createFileA = new IntCall("CreateFileA"); IntCall closeHandle = new IntCall("CloseHandle"); byte[] securityAttributes = new byte[12]; securityAttributes[0] = (byte) 12; int fileHandle = createFileA.executeCall(new Object[] "documents/file_management_test.txt", new Integer(0x80000000 | 0x40000000 | 0x00010000), null, securityAttributes, new Integer(2), null, null }); boolean closed = closeHandle.executeBooleanCall(new Integer(fileHandle)); createFileA.destroy(); closeHandle.destroy();
Who uses NativeCall?
Other resources
Subscribe
RSS 2.0, Atom or subscribe by Email.
Top Posts
- DynaCloud - a dynamic JavaScript tag/keyword cloud with jQuery
- 6 fast jQuery Tips: More basic Snippets
- xslt.js version 3.2 released
- xslt.js version 3.0 released XML XSLT now with jQuery plugin
- Forum Scanners - prevent forum abuse
- Automate JavaScript compression with YUI Compressor and /packer/