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, [...
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
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: ...
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 ...
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,
&...
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....
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 ...
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 ...
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;
...
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 '...
-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 ...
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 =...
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 ...
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
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
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
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 ...
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
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, ...
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
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
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:
...
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 ...
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
...
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 ...
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
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 ...
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 ...
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
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
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
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 ...
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.
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 ...
1
vote
1
answer
76
views
How can I get name of currently running app (same as in task manager) with Java? (Windows)
Here is my code which is supposed to print name of currently used app:
import com.sun.jna.Native;
import com.sun.jna.platform.win32.*;
import com.sun.jna.ptr.IntByReference;
public class AppList {
...
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
0
answers
97
views
Why does the Java process memory still increase after calling memory.close?
After running the following program, the memory occupied by the Java process increased from 83M to 99M. Through monitoring, it was found that the increase was almost 1.4M several times (approximately ...
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 ...
0
votes
1
answer
387
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 ...
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 ...
0
votes
0
answers
156
views
Reading and formatting events from Windows Event Log
The following code reads and prints the events from the Windows Event Log of the local computer.
import java.io.UnsupportedEncodingException;
import java.util.Date;
import com.sun.jna.platform.win32....
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 ...
1
vote
1
answer
85
views
Сan't get data from native, using the ByReference to the structure
I'm a complete beginner at JNA
I am passing an empty structure to the function, which consists of structures nested in it. After calling the function, I expect the fields to be filled in, but the ...
0
votes
0
answers
29
views
Windows - How can I prevent a JFrame from being hidden in desktop peek
Since I use Rainmeter I noticed that it does not get hidden when using desktop peek. I was wondering if I could achieve something similar in Java using maybe JNA or JNI (Other libraries work fine too ...
-1
votes
1
answer
99
views
SDK Nikon C with JNA
I'm working on a wrap between a Nikon SDK written in C and a Java program with JNA libruary.
All the process ended in a EntryPoint (MAIDEntryPoint) that is inside a dll.
The signature of this ...
1
vote
1
answer
122
views
How should I extract complicated info from struct?
I have a complicated struct in C++. Now I need take the value by JNA. I have tried some ways, but all failed. I'm not sure where the problem is.
Here is my structure in Java, it is generated by ...
0
votes
1
answer
236
views
How to use JNA with java to detect clicks
If I try to write the code below, I get the following error
Exception in thread "main" java.lang.UnsatisfiedLinkError: Error looking up function 'SetWindowsHookEx': the specified procedure ...
1
vote
1
answer
71
views
JNA Binding for Win32 function DwmGetColorizationColor returning E_INVALIDARG error
I am trying to create a binding for the Win32 function DwmGetColorizationColor using JNA.
According to MSDN, this is the function signature:
HRESULT DwmGetColorizationColor(
[out] DWORD *...