2,037 questions
1
vote
1
answer
63
views
JNA CoCreateInstance returns S_OK but ShellLink/IShellLinkW fails, COM pointer is non-null but object unusable
I'm making a Java app that scans the Windows Recent Files folder and resolves .lnk shorcuts to their actual file paths. I'm doing so using JNA the JNA API and simulating IShellLinkW and IPersistFile.
...
2
votes
1
answer
129
views
How do I create a file through JNA
In the java 25 move, we're removing some code that uses reflection in a soon-to-be-disallowed way. Instead, we're looking at using JNA. I need to access a file descriptor (the unix kind) and I thought ...
3
votes
1
answer
104
views
How to call a COM function with a Variant * parameter using JNA?
Background and environment:
I have a Windows software installed, which has a Component Model Object. The COM provides a function:
long GetValue(VARIANT* v, short a, short b, [optional] VARIANT c, [...
1
vote
1
answer
101
views
Minecraft Forge 1.8.9 Mod Works In Dev Env (Run in IntelliJ Idea) but Not when exported In-Game
When launching my minecraft forge 1.8.9 mod in a dev env (Intellij Idea) it launches perfectly fine but when exporting the mod and using it In-Game it crashes on start-up with this error:
Description: ...
0
votes
0
answers
48
views
How to intercept and modify scroll wheel events on MacOS in JVM
As you already know mouse wheel scroll does not work properly on MacOS. To fix this I tried to intercept all scroll events and modify them. This is what I have currently
import ...
1
vote
1
answer
405
views
Problems with Windows graphics capture
I'm trying to use Windows graphics API to capture windows through my Java application with the help of JNA.
I have successfully achieved this, but when running multiple captures it seems to block and ...
2
votes
0
answers
84
views
How to implement in Java a callback to be called by a COM object?
I'm integrating in Java with a DLL that allows me to add an instance to be notified.
I have tried several solutions and in none of them was the COM object able to notify me. I suspect that the way I ...
2
votes
0
answers
82
views
UnsatisfiedLinkError for Go native method with custom Java return type
I have a Go method that returns 2 byte arrays and 2 strings defined as:
// export GetDetails
func GetDetails() (unsafe.Pointer, unsafe.Pointer, *C.char, *C.char) {
...
return C.CBytes(arr1), C....
0
votes
1
answer
118
views
MAUI Project getting errors after binding android library (.aar)
I am using android library called "autoreplyprint.aar" , this library contains another.jar file called "jna-4.5.1.jar".
I have used following code to bind it in my MAUI project,
&...
1
vote
1
answer
240
views
Memory leak in unknown module reported with JNA and JUnit
This is a specific issue I found while making MRE for my earlier question. It's not clear if it's the same issue, even though it seems related, so I'm asking it as a separate question.
Consider the ...
2
votes
1
answer
68
views
What's the JNA mapping for 'unsigned char data[1]'?
I'm trying to write JNA wrappers for LibRaw and I'm stumbling over one particular C structure:
typedef struct
{
enum LibRaw_image_formats type;
ushort height, width, colors, bits;
...
-1
votes
1
answer
141
views
Using Java FX and C++ together with JNA/JNI [closed]
I'm working on a class project and about half of our group knows c++ and the other half only knows Java FX. Our project is a synthesizer, which involves a good amount of DSP and GUI stuff. I figured ...
2
votes
2
answers
266
views
How to make transparent JavaFX stage transparent for mouse events for Linux X11?
I have a transparent stage and I need when user click inside this stage then mouse event to be passed to a window that is behind my JavaFX stage (for example, if there is a text editor behind my stage ...
0
votes
2
answers
236
views
Access a C++ struct from Java using JNA
I'm new to JNA and trying to put together a very minimal proof-of-concept for accessing structs from a C++ shared library. Unfortunately, it doesn't run and I cannot figure it out.
Here's my code:
...
0
votes
0
answers
32
views
JNAerator: 2d array
I have multiple structs declared in the header files with many different primitive types as:
uint8_t, uint16_t, uint8_t[], uint8_t[], uint8_t[][], ... , uint16_t[][], ..., uint32_t[][]
In Java, when I ...
0
votes
1
answer
96
views
Access a C++ struct with two vectors from Java using JNA
This follows on from my earlier question. I now need to access a C++ struct that has multiple members of type std::vector<double> or std::vector<int>. However while I seem to successfully ...
0
votes
1
answer
65
views
Struggling with JNA wrappers for LibRaw image data pointers
Background: I'm not a professional developer - I used C a few decades ago and Java a few years ago. I'm rusty.
I'm trying to write JNA wrappers for LibRaw and I'm struggling to get the right JNA '...
15
votes
4
answers
17k
views
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 ...
0
votes
0
answers
51
views
Use JNA to call DLLS that have dependency concerns error message Invalid memory access
I created two dll libraries in C# , shuchu.dll AND yinyong.dll
The contents of shuchu dll
namespace shuchu
{
public class Class1
{
[DllExport("getInfo", CallingConvention =...
0
votes
0
answers
86
views
Issues with Loading and Calling Functions from user32.dll Using JNA in Java
I’m working on a Java application where I want to create a transparent, non-clickable window with only a clickable button. To manipulate the window’s native properties, I am using JNA (Java Native ...
0
votes
1
answer
118
views
java.lang.UnsatisfiedLinkError on calling Native.loadLibrary()
I'm trying to call a method from a .dll, using com.sun.jna.Native. It works fine when run from IntelliJ, but crashes when executed as a .jar file.
How do I fix it, so that the .jar is able to call the ...
0
votes
0
answers
63
views
JNA getting com.sun.jna.platform.win32.COM.COMException: Class not registered
I'm trying to test the ability of calling a COM compiled from C# in a Java application using JNA.
C# code:
namespace MyComLibrary {
[Guid("SOME_GUID")]
[InterfaceType(ComInterfaceType....
0
votes
1
answer
73
views
How to get rid of jna tmp can't be opened because Apple cannot check it for malicious software in Sourcetree?
Whenever I commit/push using SourceTree, I get the following popup.
It looks like SoucreTree is creating some executables on the fly.
Jna can't be opened because Apple cannot check it for malicious ...
0
votes
1
answer
130
views
JNA's IntByReference in Java Foreign Function & Memory API
I have a native .so library that has the following function:
void foo(void* handle);
It works well in C#:
[DllImport("library.so", CallingConvention = (CallingConvention) 3)]
private static ...
0
votes
1
answer
56
views
how could a random rust ABI lib include functions which are not defined?
I wrote a simple rust file as
#[no_mangle]
pub extern "C" fn add(a: i32, b: i32) -> i32 {
a + b
}
and tried to invoke it in Java.
So I loaded it and defined 2 native methods:
...
1
vote
2
answers
176
views
Apache Cassandra fails to start - SIGSEGV error when using non-default tmp directory
I'm deploying Apache Cassandra on a managed RHEL8 instance. I can install and start Cassandra successfully if I remount /tmp without the noexec flag. Overnight the noexec flag is reinstated by company ...
119
votes
10
answers
53k
views
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?
1
vote
0
answers
102
views
How to get PowerShell current directory by PID in Java?
I need to get PowerShell current directory in Java code using PowerShell PID. For example, if there is a PowerShell instance and a user is in E:\Temp directory I need to get E:\Temp. If the user does ...
2
votes
2
answers
164
views
How to access global variable via JNA interface?
I need to access a "native" C library from Java via Java Native Access (JNA). The idiomatic way to do this seems to be defining an interface that extends Library and that declares all the ...
0
votes
1
answer
38
views
UnsatisfiedLinkError with JNA on Windows x64 only
I am writing a Kotlin Multiplatform wrapper for google/leveldb. Links for context:
leveldb-builds: where the binaries are compiled for Linux, Windows, Apple and Android targets (arm32, arm64, x64, ...
58
votes
1
answer
233k
views
Understanding "corrupted size vs. prev_size" glibc error
I have implemented a JNA bridge to FDK-AAC. Source code can be found in here
When bench-marking my code, I can get hundreds of successful runs on the same input, and then occasionally a C-level crash ...
1
vote
1
answer
610
views
Cannot load native library on Android: Native library not found in resource path
I am developing a Rust library named Galileo with FFI to Android, and am trying to run it in Android emulator.
It compiles fine with the command and produces x86 directory where you'd expect:
cargo ...
0
votes
1
answer
73
views
How do I fix the Java unsatisfied link error when using JNA in Apache MiNiFi running inside a podman container
I have an Apache NiFi dataflow that transports data between two directories on my system through POSIX message queues using two NiFi processors that I made. These processors use JNA to make the calls ...
2
votes
0
answers
129
views
Windows Display Scaling affecting a JFrame
My Java application takes a screenshot of the screen and then displays it.
Normally this would be a funny prank where a user would click around and there would be no response as they're trying to ...
0
votes
0
answers
446
views
JNA library doesn't load despite being present
I'm trying to use Tesseract.
java.lang.NoClassDefFoundError: Could not initialize class
net.sourceforge.tess4j.TessAPI
I've checked if this library is found via jna debug.
Found library resource at
...
0
votes
1
answer
273
views
java.io.IOException: To use Lanterna on Windows, either add JNA (and jna-platform) to the classpath (or use javaw)
Context
I created a Lanterna TUI which works perfect on Ubuntu, and I am testing it on Windows 11. When I run the command with javaw, a separate terminal is created that is glitches as soon as one ...
8
votes
2
answers
22k
views
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, ...
1
vote
1
answer
46
views
Can't capture output on testing 'WriteFile' function call via JNA
I want to write a test which would confirm that my string is successfully printed to console via JNA using WriteFile function.
Specs:
Windows 11 Home, Version 22H2
Java 22
JNA 5.14.0
Kernel32.java
...
0
votes
0
answers
87
views
Unable to listen to WinApi messages using JNA on Kotlin Multiplatform App
Im trying to set messaging between two instances of my kotlin desktop (windows) project.
The app is a music player and the idea is that once an instance of the app is already running, new instances ...
0
votes
2
answers
846
views
What possible reasons could there be for a JVM crash in an application with JNA?
I'm looking for possible reasons for a strange issue with JNA. I have a Java application which uses bunch of shared libraries, all self made, programmed by me and my colleague. We are using JNA 5.x to ...
0
votes
1
answer
388
views
What causes a "java.lang.ClassNotFoundException: com.sun.jna.Callback" Error using maven javafx:jlink?
After making a JavaFX Application, the hardest part has been trying to export it. I am using openjfx 19 and openjdk 11 and want to export the Application using the javafx-maven-plugin javafx:jlink.
In ...
5
votes
2
answers
5k
views
Decide GNU or MUSL build of linux in Java
I have a Java desktop application which is supposed to run in both GNU Linux distributions (Debian and Ubuntu) and MUSL Linux distributions (Alpine). My application uses a native library also and ...
0
votes
2
answers
259
views
Java JNA get and pass native pointer
How using Java JNA get a pointer from a native method and pass it to another native method?
//C code .h
...
extern "C" HN2QCONN __stdcall N2QLibConnCreate(LPCTSTR lpszIniFile, LPCTSTR ...
0
votes
2
answers
150
views
How to make a proper description of Java JNA objects
Please help me create the correct JNA objects for the C code.
I have a dynamic library n2q_lib.dll . This library used its own configuration file and possibly other libraries that are located in the ...
1
vote
1
answer
624
views
How to load native library and its transitive native dependencies with JNA?
This comes up periodically but none of the answers work for me or are complete enough for me understand what is going on. For example, How to load a native API with JNA.
I can get the primary lib to ...
0
votes
0
answers
71
views
When I use the jna method, the java call to c# keeps running with an error saying "java.lang.Error: Invalid memory access"
When I use the jna method, java calls c# with a constant error.
java.lang.Error: Invalid memory access
c# code is below (64 bit),
namespace EwpDeleteBlank
{
public static class RemoveBlankPage
...
0
votes
2
answers
69
views
Converting BufferedImage to Pixmap
Is there some way to convert a BufferedImage to X11 Pixmap? It looks like JNA has com.sun.jna.platform.unix.X11.Pixmap but I can't find a way to convert anything to that format.
17
votes
7
answers
32k
views
Unable to load JNA native support library Elasticsearch 6.x
I have installed Elasticsearch 6.x in my Debian 7 (wheezy). I tried to start with service elasticsearch start but its give me an error message
root@debian:~# sudo -i service elasticsearch start
[...
0
votes
0
answers
92
views
can I use JNI/JNA to work with libcrypto-3-x64.dll?
I have install OPENSSL in my computer, and there is a file named "libcrypto-3-x64.dll" in my "system32" folder.
Can I use JNI or JNA to work with libcrypto-3-x64.dll ?
I can use ...
1
vote
1
answer
105
views
Testing native library with jna and junit: tests quit abruptly after exiting the library
I'm making a small app to test the integration of a native library (linux and windows) into java code with jna.
To do this I just call a single method into the library and check the result using ...