views:

49

answers:

3

I want to use windows apis in JRuby. Please suggest any api that can do the work of Ctypes(python).

A: 

You can use the Java JNA API

See JRuby meets the Windows API

Diaa Sami
A: 

http://blog.headius.com/2008/10/ffi-for-ruby-now-available.html

JRuby has a foreign function interface. I'm not sure about the state of windows support, but it is likely lagging behind the *nix version.

Alternatively, you can write your own wrappers using JNI and normal Java and use them through JRuby

Ben Hughes
+3  A: 

JRuby includes the FFI API which was originally created for Rubinius, but is now supported on JRuby, MacRuby, MagLev, TinyRb, MRI and YARV (the last two via the FFI gem) as well.

The FFI API is specifically designed to make it very easy to bind to C libraries, without having to actually write any C (all the mappings are written in a declarative Ruby DSL).

Daniel J. Berg, the maintainer of the win32-api gem and all the other win32 libraries is currently working on getting them to run on JRuby by porting them to FFI, but he has hit a couple of roadblocks, unfortunately.

Jörg W Mittag