jna

search paths where one native library depends on another

I'm using JNA and Java but I think this question affects any native-to-nonnative bridge. I have a Java application which relies on lib1.dylib, and lib1.dylib relies on lib2.dylib. I want to put everything inside of my .app file on Mac. I can easily put lib1.dylib inside and set java.classpath (or NativeLibrary.addSearchPath()) to tell ...

is memory allocated in JNA (or JNI) by the C code limited by jvm (param -Xmx or architecture 32/64)

that is, could a malloc() asking for 5 mb in the C part fail due to: jvm was run with -Xmx32m and jvm heap is already 30 mb something to do with jvm being 32 bits in a 64 bits windows ...

Can I mix JNA with JNI

I have a custom dll that I access from Java using JNA. So far all is working perfect. Now however I would like to create Java classes from my C code. I assume this can't be done with JNA so what I did is to create a JNI method but this leads me to UnsatisfiedLinkError's. So my question is: Can I mix JNA and JNI when accessing the same DL...

Can I someone point to me what I did wrong? Trying to map VB to Java using JNA to access the library

Original Working VB_Code Private Declare Function ConnectReader Lib "rfidhid.dll" () As Integer Private Declare Function DisconnectReader Lib "rfidhid.dll" () As Integer Private Declare Function SetAntenna Lib "rfidhid.dll" (ByVal mode As Integer) As Integer Private Declare Function Inventory Lib "rfidhid.dll" (ByRef tagdata As Byte, By...

JNA unsigned integer by reference gives strange results

I'm currently trying to access a C API using JNA. But I have a problem with unsigned integer parameters that are being passed by reference. So here is the C function in question: int EE_DataGetNumberOfSample(DataHandle hData, unsigned int* nSampleOut); In Java I have: public int EE_DataGetNumberOfSample(Pointer hData, ByReference nS...

Windows thumbnail preview with JNA (Java)

W32API.HWND targetHwnd = User32.INSTANCE.FindWindow('SunAwtFrame', 'Frame') W32API.HWND sourceHwnd = User32.INSTANCE.FindWindow('triuiScreen', 'EVE') W32API.HANDLE thumbnailH = new W32API.HANDLE() NativeLibrary dwm = NativeLibrary.getInstance('dwmapi') dwm.getFunction('DwmRegisterThumbnail').invoke(targetHwnd, sourceHwnd, thumbnailH) ...

Does the Java Native Access API locally save the native libraries for execution?

Hi All, I was just wondering if anyone knew whether the Java Native Access API will locally save the native libraries into a temporary location before or when loading and using native libraries? ...

How one extends JNA interface mappings? (Java)

User32 interface (platform library) is missing some WinAPI functions, so I tried extending it: package myapp import com.sun.jna.platform.win32.W32API public interface User32 extends com.sun.jna.platform.win32.User32 { myapp.User32 INSTANCE boolean IsWindow(W32API.HWND hWnd) } But then calling myapp.User32.INSTANCE.FindWindow(...

JNA: passing arguments as wParam/lParam (Java)

If I need to pass an integer it's pretty straightforward: User32.INSTANCE.PostMessage(hwnd, WM_MOUSEMOVE, new W32API.WPARAM(), new W32API.LPARAM(x | y << 16)) but how do I get WPARAM out of W32API.HDC for example? ...

Is it possible to access a running instance of an app using JNA/JNI?

I'm writing a test engine for a Java application that has some of the code written in C. This application uses JNI to access it's native part. In the engine I'm writing, I use Fest to control de UI and perform the tests. However, I,m blind when dealing with the part that is written in C. I wonder if I can use JNA or JNI to access the n...

CAN Controller DLL with Java Application. Unable to open CAN port.

I am creating a Java application that controls a Controller Area Network (CAN) controller via a vendor-supplied can.dll file. can.dll contains a function bool openPort(DWORD memAddr) that allows the application to establish connection with the CAN controller. I wrote a C++ test application, loaded can.dll via LoadLibrary and found this...

JNA Keyboard Hook in Windows

Hello, I have put together a JNA code for installing keyboard hook in Windows (using the JNA examples). The code compiles and everything, and I get the hook installed (I get handle to the hook successfully), also I can uninstall the hook successfully. However, the callback never get called when I press any key on the keyboard. Here is m...

JNA union structure mapping

In JNA, how do you map a union structure like the following XEvent from Xlib typedef union _XEvent { int type; /* must not be changed */ XAnyEvent xany; XKeyEvent xkey; XButtonEvent xbutton; XMotionEvent xmotion; XCrossingEvent xcrossing; XFocusChangeEvent xfocus; XExposeEvent xexpose; XGraphicsExp...

Void* example for JNA

Hi, I have been struggling to find examples on void* example in JNA. I am trying to understand how to use Pointer in JNA. For example IN C : int PTOsetApiOpt(int iOpt,void* lpValue,int iLen) Parameters: iOpt: int lpData: address from which data should be read. iLen: length of data returns int values : 0 as success or -1 as failure. ...

JNA - callback method with void* arguments

Hi, I have a C method that registers call back method with vendor provided dll. I have been told that the DLL makes the callback on a separate thread which it creates and controls.There are 3 possible different data messages that can be received by receive callback. // Register user receive callback function int PTOAPI_MODE PTOregRecei...

Calling Obj-C CoreFoundation functions from JNA with Rococoa

Hi, I'm using Rococoa in a Java project and I am a newbie with JNA. I need to cast a NSURL object to its CFURLRef equivalent and pass it to a low-level C function in CoreFoundation (to create a CFBundle). I can't figure out how to cast a Rococoa NSObject or ID to a JNA Structure reference. Any hints? Thanks. François ...

Getting hardware information using java/jna to work on all operating systems

Hi I am trying to write a java applet that will get some hard ware info, mac address(which I have done), cpuid motherboard serial number and hard drive serial number. I know I need to use jna to do this. My question is, is there a way in c/c++ to get that information that is not platform dependent? Everything i have seen would work only ...

JNA - Undefined symbol

Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'clip': /home/path/libclip.so: Undefined symbol "g_slice_alloc" I load a libclip.so library but I get this exception. I searched "undefined symbol" error on mailling lists but I did not find something useful. Anybody can help ? ...

Screen capturing inactive window

Is it possible to get image contents of an obstructed window without bringing it to the front? Also, is it possible to send mouse clicks to a specific locations of such window? I want to do this in Java, using JNA, running Windows XP (if it is possible, would it also work on Windows 7?). If that can be done, would you mind telling me wha...

Question about loading DLL (using JNA) inside an OSGi bundle

Currently I have the DLL files (rfid.dll;cpl.dll;rfidtx.dll;) at the root of my bundle. I make a Utility Bundle to hold the jna.jar, and export com.sun.jna, com.sun.jna.ptr as services. The Manifest for the bundle in question looks something like this: Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: ServiceImpl Bundle-Sym...