jna

How to call go function from java?

北城余情 提交于 2019-12-06 18:05:34
问题 How to call go function from java? 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) return x + y } 回答1: After review of the documentation about Go Shared Libraries It is possible to integrate the call Golang functions from Java Spring Batch, below a short example: Golang function: 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) return x + y }

How to dispose library loaded with JNA

萝らか妹 提交于 2019-12-06 11:45:40
问题 I'm using JNA to load a native Library using: MyLibrary INSTANCE = (MyLibrary) Native.loadLibrary("mylibrary.so", MyLibrary.class); Now I want to clean up and dispose the library. I've read about the dispose method but this is defined on the class NativeLibrary , how I am supposed to call this? Anyway, is it necessary to do that? I'm using jna with Apache Spark on a large scale, so I'm loading the library thousand of times, I'm wondering of there are any resources left open if I do nit

JNA Windows Service Startup Type

梦想与她 提交于 2019-12-06 11:26:45
I've been playing around with JNA and am able to return the status of a Windows Service (i.e. started or stopped) using the code below. I'm not sure how to return the startup type of the service though. I'm sure there are ways outside of JNA, but I would like to continue to use JNA if possible. import com.sun.jna.*; import com.sun.jna.Library.Handler; import com.sun.jna.platform.win32.*; import com.sun.jna.platform.win32.Advapi32Util.*; import com.sun.jna.platform.win32.WinNT.*; import com.sun.jna.ptr.IntByReference; import com.sun.jna.win32.*; public class WindowsService { public static void

Java JNA Mapping in Delphi Dll function

被刻印的时光 ゝ 提交于 2019-12-06 09:52:39
How do i map this function with JNA: Delphi Dll Function Code: function send_command (const command : byte; var size : byte; var data : pbyte) : integer; stdcall external 'comunication.dll'; Use example in Delphi Example Program: send_command (cmdCLOCK_ADJUST, tam, pb); Where: const cmdCLOCK_ADJUST = $18; var tam : byte; pb, p : pbyte; begin ... tam = 7; p:= pb; for i:= 1 to tam do begin p^:= Dados [i]; inc (p) end; send_command (cmdCLOCK_ADJUST, tam, pb); freemem (pb); ... end The int value that is returned can be 0 for Error or 1 for right execution; My suggestion is: JNA Java Function Code:

Query all Windows Services with JNA

牧云@^-^@ 提交于 2019-12-06 08:25:06
Currently I'm trying to query all installed Windows Services from (remote) machine. I had a look at win32.Advapi32 . But here I can only "get" a defined (I have to give a "ServiceName") Windows Services. (Advapi32.INSTANCE.OpenSCManager, Advapi32.INSTANCE.OpenService, Advapi32.INSTANCE.QueryServiceStatusEx) Do you know any API which allows to query all Windows Services from (remote) machine? EDIT:// I tried it allready with the following code. But it aborts hardly with no error message! public void getService(){ IntByReference size = new IntByReference(); IntByReference lppcbBytesneeded = new

Listening to system mouse clicks from Java

三世轮回 提交于 2019-12-06 08:01:04
问题 My main aim is to count the number of mouse clicks on a particular application. Imagine I have opened Microsoft Word and a web browser on my PC. My Java code should tell me how many times I clicked on Word and on the web browser. I need the application name and the number of clicks. How can I do this? Any solution must work for MAC, Linux and Windows. 回答1: You could try a library such as jnativehook: http://code.google.com/p/jnativehook/. Check out their examples on this page. This library

Kernel32.INSTANCE.ReadProcessMemory REALLY Slow In JNA

倖福魔咒の 提交于 2019-12-06 07:59:48
I'm writing a game hack which uses memory manipulation to work and decided to do it in Java for the FUD aspect (native hacks can be detected almost immediatly). I have this method which reads a memory object from the windows call ReadProcessMemory public static Memory readMemory(Pointer process, long address, int bytesToRead) { Memory output = new Memory(bytesToRead); KERNEL32.ReadProcessMemory(process, address, output, bytesToRead, 0); return output; } Memory output = new Memory(bytesToRead); Takes about 0-5+ms to execute sometimes KERNEL32.ReadProcessMemory(process, address, output,

problem using JNA and EnumWindows

↘锁芯ラ 提交于 2019-12-06 05:51:15
问题 I'm experimenting with JNA, and this is the first program I try to run. I copied it from the reference, but, when i run it, he finds 412 windows ... and I'm quite sure I've not that many window opened right now :) Can please someone explain me the behaviour of the program? import com.sun.jna.Pointer; import com.sun.jna.win32.StdCallLibrary.StdCallCallback; import com.sun.jna.Native; import com.sun.jna.win32.StdCallLibrary; public class Main { // Equivalent JNA mappings public interface User32

Android - JNA library

给你一囗甜甜゛ 提交于 2019-12-06 05:02:37
Hello i'm using JNA to be able to use an external .dll(i don't have the header file but i have documentation thus the exposed function signatures). I have managed to use my dll in a java project following the instructions here and now i'm trying to use the same thing on an android app. I imporetd the jna jar in my libs and also added the jar in my buildpath and i'm getting an error The library 'jna-3.5.1.jar' contains native libraries that will not run on the device. The following libraries were found: com/sun/jna/linux-amd64/libjnidispatch.so com/sun/jna/darwin/libjnidispatch.jnilib com/sun

Call a non-reentrant native shared library from multiple Java threads

巧了我就是萌 提交于 2019-12-06 03:47:25
问题 I have some Java code that is calling some native code, originally written in Fortran, using JNA. (It's a numerical library, and lots of math people do their coding in Fortran.) It is compiled to a .so library, see below: Fortran: https://github.com/mizzao/libmao/tree/master/src/main/fortran Java binding: https://github.com/mizzao/libmao/blob/master/src/main/java/net/andrewmao/probability/MvnPackDirect.java I was getting great results with everything unit tested in my code, but then I tried