jna

Detecting thread interruption with JNA native wait call (Windows)

Deadly 提交于 2019-12-01 10:54:21
I'm trying to write some code that performs a wait via JNA (e.g. by calling the Kernel32 function WaitForSingleObject), but I'd also like the wait to finish if Thread.interrupt() is called; I assume Java uses something like an Event object to implement interruption; is there any way of getting the Event from Java in order to use it in a call to WaitForMultipleObjects? Or is there any other way I could arrange for my wait to finish if the thread is interrupted? Java supports it via NIO and very few people are aware of, the class in question is abstract but that's no issue: java.nio.channels.spi

JNA调用DLL

。_饼干妹妹 提交于 2019-12-01 10:02:14
1.引入pom <dependency> <groupId>net.java.dev.jna</groupId> <artifactId>jna</artifactId> <version>5.2.0</version> </dependency> <dependency> <groupId>net.java.dev.jna</groupId> <artifactId>jna-platform</artifactId> <version>5.2.0</version> </dependency> 2.JnaDemo import com.sun.jna.Library; import com.sun.jna.Native; import com.sun.jna.Platform; public class JnaDemo { public interface CLibrary extends Library { //调用动态链接库c://windows/system32/msvcrt.dll中的printf函数输出hello world CLibrary INSTANCE = (CLibrary)Native.loadLibrary((Platform.isWindows() ? "msvcrt" : "c"),CLibrary.class); void printf(String

Get PID from ShellExecute

柔情痞子 提交于 2019-12-01 08:45:08
I am launching a process from ShellExecuteEx, and I really need to get the ProcessID (It's part of the requirement of this class). Somehow all the important SHELLEXECUTEINFO returns null. So for example if I use this code: exInfo.lpVerb = "open"; exInfo.lpFile = "C:\\Windows\\system32\\cmd.exe"; exInfo.nShow = 5; ShellExecuteExA(exInfo); It launched CMD.exe. But now I need to get it's PID. exInfo.hwnd is returning 0 , and exInfo.hProcess is returning null . Is this normal behaviour? I don't really want to resort to using CreateProcess(), because my function should also be able to launch

JNA: Native Library dependencies and JAR extraction

点点圈 提交于 2019-12-01 08:15:05
I will access the MSP430.dll (see here) via JNA. But this library has a dependency to other native library, which cames bundled with the MSP430.dll. This dependend native library is called HIL.dll. With use of jna.library.path all does work perfect. Now I would bundle the native librarys to my own .jar package. Then I would use the automatic native library loading from jar of the JNA framework. But this makes problems with native librarys that have dependencies. If I package the MSP430.dll and HIL.dll to my .jar package then I get following error: "JNA java.lang.UnsatisfiedLinkError and The

Get PID from ShellExecute

早过忘川 提交于 2019-12-01 07:45:59
问题 I am launching a process from ShellExecuteEx, and I really need to get the ProcessID (It's part of the requirement of this class). Somehow all the important SHELLEXECUTEINFO returns null. So for example if I use this code: exInfo.lpVerb = "open"; exInfo.lpFile = "C:\\Windows\\system32\\cmd.exe"; exInfo.nShow = 5; ShellExecuteExA(exInfo); It launched CMD.exe. But now I need to get it's PID. exInfo.hwnd is returning 0 , and exInfo.hProcess is returning null . Is this normal behaviour? I don't

Detecting thread interruption with JNA native wait call (Windows)

こ雲淡風輕ζ 提交于 2019-12-01 07:29:33
问题 I'm trying to write some code that performs a wait via JNA (e.g. by calling the Kernel32 function WaitForSingleObject), but I'd also like the wait to finish if Thread.interrupt() is called; I assume Java uses something like an Event object to implement interruption; is there any way of getting the Event from Java in order to use it in a call to WaitForMultipleObjects? Or is there any other way I could arrange for my wait to finish if the thread is interrupted? 回答1: Java supports it via NIO

JNA native support (/com/sun/jna/linux-arm/libjnidispatch.so) not found in resource path

若如初见. 提交于 2019-12-01 05:59:28
I have started to build a java service which incorporates JNA to load a native C/C++ lib and i want to run the java service on the Raspberry PI aka arm platform. I have successfully built a stable ground of the service and it runs on both Windows7 and linux-amd64/debian but.. on the RPI platform i get the above stated error: Exception in thread "main" java.lang.UnsatisfiedLinkError: JNA native support (/com/sun/jna/linux-arm/libjnidispatch.so) not found in resource path On the RPI i have done the following: * Installed both openjdk7 and java8 beta with arm hard float support. * Installed

JNA native support (/com/sun/jna/linux-arm/libjnidispatch.so) not found in resource path

醉酒当歌 提交于 2019-12-01 04:37:03
问题 I have started to build a java service which incorporates JNA to load a native C/C++ lib and i want to run the java service on the Raspberry PI aka arm platform. I have successfully built a stable ground of the service and it runs on both Windows7 and linux-amd64/debian but.. on the RPI platform i get the above stated error: Exception in thread "main" java.lang.UnsatisfiedLinkError: JNA native support (/com/sun/jna/linux-arm/libjnidispatch.so) not found in resource path On the RPI i have done