jna

JNA load .a/.lib library

Hi, i'm trying to write jna mapping for libfaad2. The library uses mp4ff for parsing mp4 files. mp4ff is compiled into libmp4ff.lib on windows and libmp4ff.a on linux. JNA only looks for .dll/.so files. So how can I load this mp4ff into jna? EDIT I think this question has the answer. I hate AAC, I've spent 4 days debugging invalid memo...

Wrapping BSD select() with JNA

I need to wrap a BSD-like C socket API to Java with JNA. It has basically the same functions as standard BSD socket API. Wrapping select() is problematic because of the fd_set-structure required in its arguments and the FD_* masking functions (macros) that are needed to handle fd_sets. I tried to crawl through the header files (e.g. sys...

Pass InputStream through JNA to C code as a File Pointer

I've got a DLL written in C (that I can't edit) that has some function prototype that looks like #include <stdio.h> void foo(FILE *bar); I'd like to create a JNA interface to the DLL and it's unclear what I need to pass for the FILE *bar argument. I assume I need to pass an InputStream (which is my preference), but the JNA literature...

Load DLL (using JNA) inside an OSGi bundle

OSGi cannot find my DLL file, and I can't seem to figure out why. Currently I have the DLL file (foo.dll) at the root of my bundle, I've also tried having it in a libs directory. The Manifest for the bundle in question looks something like this: Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: foobundle Bundle-SymbolicName...

Help returning C array to Java using JNA

I am not too familiar with C, but I need to use a C library in my java code. I have created the DLL and am able to access it just fine, but I am attempting to return an array of ints from the C code to the java code. In C I thought you could simply return a pointer to the array, but it's not working like I expect in my Java code. Here...

What's the equivalent to IntPtr (C#) in Java?

What's the equivalent to IntPtr (C#) in Java (JNA)? ...

JNA-Mapping Delphi Function

Hi! How do i map this function with JNA: Delphi code: function getData(InData1: PChar; InData2: PChar; Data: TArray16; var OutData1: PChar; var OutData2: PChar): integer; stdcall; with: TArray16 = array[0..15] of char; The int value that is returned can be 0 fo...

Use JNI instead of JNA to call native code?

JNA seems a fair bit easier to use to call native code compared to JNI. In what cases would you use JNI over JNA? ...

Creating a CFString object with JNA

I'm trying to get the hang of using JNA with Mac OS X. I want to access a Carbon library, for which there is no Cocoa equivalent, so Rococoa can't help me (I think...) I'm stuck when trying to call a Carbon function that requires CFStringRef as a parameter. How can I create a CFStringRef from a Java String? Here's my attempt so far: ...

JNA Resources for OS X

I am looking for reading material on using JNA on OS X, there lots of examples on the web for windows but i can't find anything for OS X. I know that the idea is the same but i have zero cocoa experience. So anyone know any simple examples of using JNA to access cocoa functions? ...

Invalid memory access of location with Rococoa

I've been trying to code a simple screenshot application using rococoa (java to osx cocoa api library), and managed to get as far as actually taking the screenshot, and then saving it to a file. Unfortunately, once in a while, the application fails with an 'Invalid memory access of location...' error. I'm assuming this is due to somethin...

jna call to kernel32.CreateToolhelp32Snapshot in shutdown hook crashes the VM

If a thread sets a shutdown hook using Runtime.getRuntime().addShutdownHook(); calls via jna the method: kernel32.CreateToolhelp32Snapshot (0x00000002, 0) it crashes the VM. If I call the same method in the WindowListener.windowClosing() hook, the call does not crashes the VM. Any idea why? I can post part of the VM crash e...

Locating Libraries

I am playing with JNA on Mac OS X and Linux. My question is if i am looking for a function "if_nametoindex" how to figure out which library to load? Most of the example i could find concentrate on Windows and they load "kernel32". ...

Java JNA GetWindowTextA does not return

Java JNA GetWindowTextA does not return for certain window if and only if the application has no GUI window. When the same application runs with SWT GUI front end, everything is OK. I don't know what is the problematic window wndenumproc to check all windows. ...

JNA ByteBuffer statvfs

I am trying to get the free space on the / folder using statvfs call from java, I have check the size of statvfs struct from c it shows 44 bytes, I have allocated a byte buffer using java.nio.ByteBuffer.allocateDirect 44 bytes, and it's order is set to 44 bytes. when i call statvfs i get a return value of 0, so i am assuming call is suc...

JNA/ByteBuffer not getting freed and causing C heap to run out of memory

Let me start by saying that my understanding of how JNA and Java direct native memory allocations is visceral at best, so I'm trying to describe my understanding of what's going on. Any corrections in addition to responses would be great... I'm running an application that mixes Java and C native code using JNA and am running accross a ...

How do I compile and run this Java Native Access (JNA) example?

I can compile this JNA example code (from step 2 of https://jna.dev.java.net/#getting_started): package com.sun.jna.examples; import com.sun.jna.Library; import com.sun.jna.Native; import com.sun.jna.Platform; /** Simple example of JNA interface mapping and usage. */ public class HelloWorld { // This is the standard, stable way o...

The jnaerator's SimpleMeaningfulExample for generating Java JNA wrappers won't work.

I tried the jnaerator SimpleMeaningfulExample (http://code.google.com/p/jnaerator/wiki/SimpleMeaningfulExample) and got: $ java -jar jnaerator-0.9.2.jar -library Test Test.h -o . -v Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number in .class file at java.lang.ClassLoader.defineClass1(Native Me...

JNA - calling methods upon C++ instance passed back from DLL

Say I have a C++ DLL with a single exported method such as: CustomerProcessor* getInstance(); i.e. it simply returns an instance of the class that actually contains the methods I need to call. I know I can map the getInstance() method to a Class in Java using JNA (extending com.sun.jna.Library), store the returned CustomerProcessor i...

Using CFBooleanRef through JNA

I'm using JNA to call Carbon APIs. The particular API call that I want to call takes a CFBooleanRef as a parameter. The values, kCFBooleanTrue and kCFBooleanFalse, are declared as direct extern references in the header files. How can I get references to those two values on the Java side, so that I can pass the values to the API call ? ...