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
11
votes
4 answers

Java Native Access doesn't do C++, right?

I've found many references online (including some on stackoverflow) to JNA being used for C++ libraries, but nothing I can find in the JNA docs indicates that's possible. There doesn't seem to be any way to wrap a C++ class, in particular. I need…
Yuvi Masory
  • 2,644
  • 2
  • 27
  • 36
11
votes
5 answers

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…
Mark Elliot
  • 75,278
  • 22
  • 140
  • 160
10
votes
3 answers

JNA library slower screenshot than robot class?

Since Robot.createScreenCaputure() method is slow, I decided to use native library. I searched and found this forum and find a specific code snipplet which uses JNA Library. It's an old version so that I rewrote the code: import…
Cihad Turhan
  • 2,749
  • 6
  • 28
  • 45
10
votes
4 answers

How to run Java application at system startup on Windows/Linux/MacOS?

How I can run Java application at system startup on Windows/Linux/MacOS? Any implementation of JNA/JNI shall be welcome.
Rajeev
  • 4,571
  • 2
  • 22
  • 35
10
votes
2 answers

JNA maps Java boolean to -1 integer?

I am getting a suprising warning from the native library I am using when passing a boolean value in a JNA structure: value of pCreateInfo->clipped (-1) is neither VK_TRUE nor VK_FALSE In this library VK_TRUE and VK_FALSE are #defined as 1 and 0…
stridecolossus
  • 1,449
  • 10
  • 24
10
votes
6 answers

Java: load shared libraries with dependencies

I am wrapping a shared library (written in C) with Java using JNA. The shared library is written internally, but that library uses functions from another external library, which again depends another external library. So the situation is something…
user422005
  • 1,989
  • 16
  • 34
10
votes
3 answers

Java - Window Image

Does anyone know how to capture a screen shot in Java (not it's own screen, but any other window on the desktop and they don't necessarily have to be the active window) in Windows? There are a number of threads here on this similar subject, but I…
rog8gm
  • 169
  • 2
  • 2
  • 10
10
votes
1 answer

Passing a Java class into a void* parameter with JNA

I have a function in C which I'm trying to call from Java with JNA: int myCfunc(void *s, int *ls); According to the JNA documentation the void* requires a com.sun.jna.Pointer be passed to the function. In java with JNA I believe the above function…
Iain Sproat
  • 5,210
  • 11
  • 48
  • 68
10
votes
1 answer

difference between com.sun.jna and net.java.dev.jna?

I'm looking through the central maven repository and seeing a net.java.dev.jna and a com.sun.jna groupId for JNA. The github for JNA, using the com.sun.jna path as the directories in their source code, indicates that 4.1 has been pushed into the…
user
  • 4,920
  • 3
  • 25
  • 38
10
votes
3 answers

How can i get a printer's make and model in Java?

I'm actually working on a Java application that shares printers to a server, and I need this application to get the make and model of the printers it shares. I know this question has been asked three or four times but nobody seems to have found an…
Padrus
  • 2,013
  • 1
  • 24
  • 37
9
votes
3 answers

How to move (or do anything with) the mouse

How to interact with the Windows API using Java and the JNA (Java Native Access)?. I'm trying to make the mouse do something by queuing a mouse event on the mouse input stream, and the code works, in that the SendInput(...) method returns 1…
Hovercraft Full Of Eels
  • 283,665
  • 25
  • 256
  • 373
9
votes
2 answers

JNA Catching Exceptions

I have a quick question about dealing with exceptions being thrown by libraries under JNA... When I throw an exception in the underlying native code, JNA gets a invalid memory access error. I'm assuming this is because C libraries cannot throw an…
StrangeWill
  • 2,106
  • 1
  • 23
  • 36
9
votes
2 answers

UnsatisfiedLinkError for M1 Macs while running Play server locally

When running a new project utilising LeadIQ's play boilerplate, we will run into an UnsatisfiedLinkError in older versions of JNA below version 5.7.0. I think this is due to incompatible binaries between the ARM M1 architecture. How can it be…
Zack
  • 189
  • 1
  • 6
9
votes
6 answers

JNA UnsatisfiedLinkError, but jna.library.path is set

I'm using the following code to load a dll in JNA (irrelevant code is left out): public class JNAMain { public interface PointShapeBuffer extends Library { ... } public static void main(String[] args){ …
Dave86
  • 91
  • 1
  • 1
  • 3
9
votes
3 answers

How to get the x and y of a program window in Java?

Is there a way for me to get the X and Y values of a window in java? I read that I'll have to use runtime, since java can't mess directly, however I am not so sure of how to do this. Can anyone point me some links/tips on how to get this?
Pedro Cimini
  • 175
  • 1
  • 1
  • 7