Questions tagged [jna]

Java Native Access (JNA) provides pure Java access to native shared libraries without the need for additional native or JNI code.

Project website

Resources

1997 questions
9
votes
3 answers

How to obtain a new Pointer in Java?

How can I call a method with this method signature in C from JNA? int open_device(context *ctx, device **dev, int index); The last two lines of the C method look like this: *dev = pdev; return 0; That's the only use of dev in that method. That…
thejh
  • 44,854
  • 16
  • 96
  • 107
9
votes
3 answers

Setting up JNA in Android Studio

I try to import jna.jar into my project since JNA is a very useful tool to call Native library which is base on JNI. OS: Windows 10 IDE: Android Studio 1.5.1 JDK: 1.8.0_73 NDK: r10e What I have done (AS = Android Studio) Create a new project by AS…
Pow Lee
  • 91
  • 1
  • 1
  • 3
9
votes
1 answer

How do I make a target library available to my Java app?

Using JNA, the documentation says: Make your target library available to your Java program. There are two ways to do this: The preferred method is to set the jna.library.path system property to the path to your target library. This property is…
MalcomTucker
  • 7,407
  • 14
  • 72
  • 93
9
votes
1 answer

Use ImageSearchDll.dll in Java ( from AutoIt ) edit: JNA

I want to react on a screen event in my Java Programm so i want to find a Image in my actual screen. I tried to write a method to get a Screenshot from the robot class and then search the pixels - but it took way to long. I know that in AutoIt there…
Dominik
  • 133
  • 1
  • 9
9
votes
5 answers

How to check if a file is readable?

I'm writing Java 6 application and I have to check if a file is readable. However, on Windows canRead() always returns true. So I see that probably, the only solution could be some native solution based on WINAPI and written in JNA/JNI. But, there…
peter
  • 631
  • 2
  • 7
  • 18
9
votes
5 answers

How to map enum in JNA

I have the following enum how do i map in jna ?? This enum is further referenced in structure. typedef enum { eFtUsbDeviceNotShared, eFtUsbDeviceSharedActive, eFtUsbDeviceSharedNotActive, eFtUsbDeviceSharedNotPlugged, …
Abdul Khaliq
  • 2,423
  • 12
  • 40
  • 65
9
votes
3 answers

Java: Making a window click-through (including text/images)

I want to create an overlay in Java that is transparent, always on top, and that I can click-through. I've found some similar posts about this issue, but even after following their answers, I'm having one issue. My problem is making the whole window…
Carl Johnsson
  • 91
  • 1
  • 3
9
votes
4 answers

How to tell Proguard to avoid obfuscating JNA library classes?

In other words: what -keep commands should I use to tell Proguard to avoid obfuscating my classes that represent native libraries? (since JNA requires that the names match the equivalent native function, struct, etc.)
Kevin K
  • 9,344
  • 3
  • 37
  • 62
8
votes
2 answers

Start/Stop services using JNA

I am writing a utility to start and stop windows services. The program will be distributed across many computers with differing levels of user privileges so I don't want to use the command line. I've tried using JNA, import…
GEverding
  • 3,131
  • 2
  • 21
  • 23
8
votes
1 answer

32Bit Native Code, JNA and a 64Bit JVM

I'm developing a java application, using a 32Bit native library which I'm accessing via JNA. On MacOS X Snow Leopard it's possible to pass the parameter "-d32" to the JVM, which causes the JVM to start in 32Bit mode. I've got a launcher application,…
aRestless
  • 81
  • 1
  • 2
8
votes
1 answer

get pointer of byte array in jna

I have following code in c# and need similar functionality in java using JNA: IntPtr pImage = SerializeByteArrayToIntPtr(imageData); public static IntPtr SerializeByteArrayToIntPtr(byte[] arr) { IntPtr ptr = IntPtr.Zero; …
user206646
  • 191
  • 1
  • 3
  • 9
8
votes
1 answer

C callback with JNA makes JRE crash

I'm having problems handling callbacks in JNA. I'm trying to use a C API that uses callbacks to handle several session events (logged in, logged out, connection problem...). The session object (called sp_session) is an opaque struct. All the…
nbarraille
  • 9,926
  • 14
  • 65
  • 92
8
votes
1 answer

How to create multiple instances of the same library with JNA?

I have a problem with Java Native Access: I have a C-library with one function, let' s say foo(). This function has a memory - a counter - with increases with every call. Is it possible to create two instances of this library within the same java…
Jens
  • 81
  • 5
8
votes
1 answer

global hotkeys in Java

I'm trying to make an app that uses global hotkeys, and I've been stuck in it for about 2 days trying to figure it out, before deciding to use jintellitype api. I always get a problem when I run the example provided on Jintellitype's website : …
a.u.r
  • 1,253
  • 2
  • 21
  • 32
7
votes
3 answers

JNA Memory Leak

Given this C++ Code: void LoadData(char** myVar) { std:: string str("[Really Long String Here]"); unsigned int size = str.length() + 1; *myVar = new char[size]; strncpy(*myVar, str.c_str(), size); } And this JNA Java: Pointer myVar…
StrangeWill
  • 2,106
  • 1
  • 23
  • 36