The ctypes4j library

overview :: tutorial

Overview

ctypes4j is a Java library that enables calling legacy C functions without coding JNI. This enables simple and rapid prototyping when platform integration is required. Ctypes4j achieves this by providing classes that enable both the creation and manipulation of C data types in Java, and the calling of C level functions in dynamic link libraries/shared dlls. It is based on (and named after) the Ctypes module for Python, by Thomas Heller et al.

CTypes4j aims to provide a simple to use method for platform integration without requiring a JNI programming.

It currently works on Windows & Linux. With a little configure effort, other unices should work.

News

Version 0.9, 13 Nov 2005

    Union type added

Version 0.8, 15 April 2005

    More unit tests. Addition of pin method to pin a CType into a C level memory representation.

Version 0.7, 29 Aug, 2004

    Synchronized FFI code with ctypes-python 0.9.1

    Example Windows GUI API Application from JAWIN included

Version 0.2, 22 Mar, 2004

    Callbacks working for Win32.

    Synchronized C code with ctypes-python 0.6.3

    Linux port working for calling functions.

    CStructs now introspect their component types. Alternatively the array based constructor still works.

    Reliable memory management between C and Java.

Version 0.1.0, 03-08-2003:

    Initial Release

Related works

Steve Holloway maintains the Java/COM, Java/Win32 Integration resources. In Steves classification system, CTypes4j is a proxy product.

Documentation

A tutorial is included in the source distribution, but also available online. You should also read the sample files in the source distribution.

Support

Support may be obtained in the mailing lists common to ctypes java and python.

Building

For those without the inclination or resources to build the JNI component of ctypes4j, a prebuild DLL and shared library are included in the respective platform distributions.

For building on WIN32, the visual C++ compiler is currently required. The project and workspace files are those reliable way to build. For building under linux, you will need to first build and install the gcc-libffi-snapshot20030119.tar.gz snapshot of libffi, downloaded from the ctypes/python SF project. The autoconf build does not yet work for linux, you must manually edit the Makefile for now.

Downloads

The release can be downloaded in the sourceforge files section.

The release archives contain all the sources, the documentation you are reading here, unit tests, and example files in a src subdirectory. Looking at the examples is highly recommended in addition to reading the documentation.

These files are distributed under the MIT license.

 


SourceForge.net Logo
Page updated: Thu Mon 30 March 2004