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
6
votes
1 answer

Calling GetOpenFileName through JNA fails for Swing app

I'm trying to use the native Windows file dialog in Java, using JNA to call the comdlg32 function GetOpenFileName. I've made a static method, OpenFileDialog.display that looks like this: public static List display(Window parent, boolean…
perp
  • 3,883
  • 4
  • 31
  • 29
6
votes
2 answers

How to use JNA in .dll and .so with the same callback signature

I'm working on a java project to run on both Windows and Linux, and I'm using a third party shared library available to both operating systems with the same methods' signature. But, the dll's calling convention is stdcall while the shared object is…
Fernando
  • 101
  • 2
  • 4
6
votes
1 answer

JNA's W32API.* - where are they?

I just downloaded both jna.jar and platform.jar (ver. 3.2.7) from http://java.net/projects/jna/downloads/directory/3.2.7 and according to http://jna.java.net/javadoc/platform/com/sun/jna/platform/win32/W32API.html I should find the W32API interface…
JoeSlav
  • 4,479
  • 4
  • 31
  • 50
6
votes
3 answers

Getting JNA to work with Java => C#?

I've written a lot of code in a C# library, which I now need to call from Java. I saw it recommended on SO to use JNA, but I'm having trouble even getting out of the starting blocks; the documentation there is very sketchy. Firstly, it only appears…
Shaul Behr
  • 36,951
  • 69
  • 249
  • 387
6
votes
2 answers

Error linking JNA library on AdoptOpenJDK on MacOS

I am trying to run some JUnit tests over cassandra. But I get the following error: [08/12/19 10:48:40:411](main)([]) INFO - c.h.c.c.e.EmbeddedCassandra - Starting embedded Cassandra server. 8/12/19 10:48:41:497](main)([]) ERROR -…
6
votes
2 answers

How can I declare an uint8_t array in Java

I have a C++ Function in my DLL that needs an uint8_t array as an input Parameter, so the array looks something like that: uint8_t input[input_length] = { 0x30, 0x41, 0x80, 0x8A...}; I want to use this function in Java with JNA, which means I have…
conryyy
  • 127
  • 1
  • 9
6
votes
4 answers

renaming DLL functions in JNA using StdCallFunctionMapper

I'm trying to use JNA with a DLL in Windows, so far I was able to successfully call a function called c_aa_find_devices(). But all the functions start with c_aa and I would like to rename it to find_devices(). From what I gather the way to do this…
Jason S
  • 184,598
  • 164
  • 608
  • 970
6
votes
1 answer

JavaFX Minimizing & Maximing undecorated stage with animations

I am using the accepted answer in this question: JavaFX Minimizing Undecorated Stage to minimize my app properly. However, unfortunately the default Windows minimize & maximize animations are not shown at all (the window just appears and…
user38725
  • 876
  • 1
  • 10
  • 26
6
votes
1 answer

How can I call a Go function from Java using the Java native interface?

It is possible to call C methods through the JNA interface in Java. How can I reach the same functionality with Go? package main import "fmt" import "C" //export Add func Add(x, y int) int { fmt.Printf("Go says: adding %v and %v\n", x, y) …
dmotta
  • 1,843
  • 2
  • 21
  • 32
6
votes
2 answers

JNA Struct and Pointer mapping

How does one map the function below to java? VOID WriteToStruct(BOOL *Status, STRUCT_MSG RecBuff) What this function does: 1) Populates the struct RecBuff 2) Updates status How do I map to a boolean pointer in Java and access the struct data…
llang
6
votes
2 answers

Problem in accessing dll file from a Java program through JNA

I have a dll file and I am trying to call functions of it through a Java program through JNA But the problem is It is not able to locate my dll file and throwing the following exception: java.lang.UnsatisfiedLinkError: Unable to load library…
Amit
  • 33,847
  • 91
  • 226
  • 299
6
votes
1 answer

JNA two dimensional arrays

I try to call a short** in C with JNA. The C looks like this: void compute(short** in, int row, int col) { for (int i = 0; i < row; i++) { for (int j = 0; j < col; j++) { printf("in[%d][%d] = %d\n", i,j, in[i][j]); …
6
votes
1 answer

JNA direct vs interface mapping?

Sorry, this maybe a basic question. What are the difference between JNA direct mapping and interface mapping? Is my interpretation correct: Direct mapping: use the library object directly (like static main in Java) Interface mapping: create an…
RockTheStar
  • 650
  • 1
  • 8
  • 21
6
votes
1 answer

JNA: Set struct pointer to NULL

I am starting to use JNA to communicate with a device on the RS485 interface of a computer. Suprisingly to me I came to good results very quickly. But now I am stuck by a simple problem. The library I use accepts a pointer to a pointer of struct.…
Sebastian Götz
  • 459
  • 7
  • 15
6
votes
1 answer

How should I pass and return unsigned int by value from Java to C/C++ in jna

My C++ function extern "C" { DECLSPEC unsigned int STDCALL doNumberThing(unsigned int some_number); } My Java Interface package com.myplace.nativeapi; import com.sun.jna.Library; import com.sun.jna.Memory; import com.sun.jna.Pointer; interface…
deworde
  • 2,679
  • 5
  • 32
  • 60