jna

Registering multiple .dll libraries into a single java class using JNA

筅森魡賤 提交于 2019-12-13 19:08:45
问题 First of all some context, to thoroughly explain the methods I've already tried: I'm working in a java-based programming platform on windows which provides access to custom java functions with several other extensions. Within the source code of this modelling platform, there is a class "CVODE" which grants access to native library "cvode" to import the functionality of a C++ library CVODE. //imports public class CVODE { static { Native.register("cvode"); } public static native int ... /

JNA causing EXCEPTION_ACCESS_VIOLATION?

回眸只為那壹抹淺笑 提交于 2019-12-13 16:32:00
问题 My Java UI unexpectly terminated and dumped an hs_err_pid file. The file says "The crash happened outside the Java Virtual Machine in native code." JNA is the only native code we use. Does anyone know of any know issues or bugs with any JNA version that might cause this. I've included some of the contents from the error file below. An unexpected error has been detected by Java Runtime Environment: EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6d02bcbd, pid=312, tid=3616 Java VM: Java

NoSuchFieldError: RESOURCE_PREFIX with a maven project using tess4j

北战南征 提交于 2019-12-13 16:30:16
问题 tess4j is an OCR packed with native library, I made a maven project to test it, I did add the installation path of maven to eclipse. I added M2_HOME, MAVEN_HOME and JAVA_HOME env variable, here is my parent pom <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>fr.mssb.ongoing</groupId> <artifactId

“global” KeyListener using JNA

拈花ヽ惹草 提交于 2019-12-13 11:32:21
问题 I have in plan making of program in Java running under Windows that can map diffenrent "macros" on different keys runnig at background. Problem is - how to make Java listen to keys pressed when the application is not being focused. I have found lot of opinions that this is not possible. But I have also found this written by Stefano here on SO. This solution is, well, not good enough for me, at least there is not one impotant information. The function MsgWaitForMultipleObjects() returns one

How to determine the currently active code page from a Java console application on Windows?

自闭症网瘾萝莉.ら 提交于 2019-12-13 10:23:31
问题 This is a simple Java application which displays the default code page on Windows: package doscommand; import java.io.IOException; import java.io.InputStream; public class DosCommand { public static void main(String[] args) throws IOException { InputStream in = Runtime.getRuntime().exec("chcp.com").getInputStream(); int ch; StringBuilder chcpResponse = new StringBuilder(); while ((ch = in.read()) != -1) { chcpResponse.append((char) ch); } System.out.println(chcpResponse); // For example:

Java crashes when calling dll function using JNA

谁说我不能喝 提交于 2019-12-13 08:24:44
问题 I'm using JNA to run a dll function: Here is all the code corresponding to that manner: The Native Declarations: //how the method declared H264_Login (char *sIP, unsigned short wPort, char *sUserName, char *sPassword, LP_DEVICEINFO lpDeviceInfo, int *error, ,SocketStyle socketTyle=TCPSOCKET); // where LP_DEVICEINFO is a struct //how the struct declared typedef struct _H264_DVR_DEVICEINFO { SDK_SYSTEM_TIME tmBuildTime; // the "SDK_SYSTEM_TIME" is another struct char sSerialNumber[64]; int

JNI Structure Alignment

a 夏天 提交于 2019-12-13 06:15:50
问题 I'm calling a DLL compiled with the VisualStudio 2005 with the "#pragma pack(1)" setting. So the structure alligment (SA) is without padding for fast data access [1]. I think the JVM is compiled with normal structure alligment [2]. So I want to know what are my options? The call to the dll(I'm not in Codecontrol) is going through a wrapper dll (I'm in Codecontrol). Can I call out of the Wrapper a dll with another SA setting? So that the Wrapper-Dll, which is called from Java uses the normal

JNA ByteBuffer statvfs

老子叫甜甜 提交于 2019-12-13 03:45:25
问题 I am trying to get the free space on the / folder using statvfs call from java, I have check the size of statvfs struct from c it shows 44 bytes, I have allocated a byte buffer using java.nio.ByteBuffer.allocateDirect 44 bytes, and it's order is set to 44 bytes. when i call statvfs i get a return value of 0, so i am assuming call is successful, but i can't seem to get information out of ByteBuffer using buffer.getInt returns 512 f_bsize which is correct but after that i can't read. buffer

Tess4J error after distributing as war NoClassDefFoundError: Could not initialize class net.sourceforge.tess4j.TessAPI

a 夏天 提交于 2019-12-13 02:46:17
问题 I have Spring boot Webserver project which works ok in my PC under Intellij IDEA, but it not works after distributing to the same PC as war file - NoClassDefFoundError: Could not initialize class net.sourceforge.tess4j.TessAPI . my code: ITesseract instance = new Tesseract(); // JNA Interface Mapping instance.setDatapath(new File(datapath).getPath()); instance.setLanguage("eng"); try { String result = instance.doOCR(imageFile); } catch (TesseractException e) { System.err.println(e.getMessage(

how to call methods with leading underscore and traling @ in JNA

喜欢而已 提交于 2019-12-12 18:24:04
问题 I have to call methods in dll but their names are like these _setParameterX@12 and _getParameterX@20 using Java Native Access. How can I properly use FunctionMapper or StdCallFunctionMapper? How do I invoke these functions? The jna documentation is a little vague to me. 回答1: Those functions use the stdcall calling convention. The suffix indicates the size of the incoming arguments on the stack. You should use the StdCallFunctionMapper to automatically generate the appropriate mappings. Create