In my app, I am adding third party hardware connectivity and using their provided code for java. Also using jna.jar to interact with that code as it uses native library to load some .so files. It throws the error:
java.lang.UnsatisfiedLinkError: Native library (com/sun/jna/android-arm/libjnidispatch.so) not found in resource path (.) Please help where can I get the jar with android-arm/libjnidispatch.so in it.`
I tried adding android-arm.jar which is having libjnidispatch.so separately but compiler is looking for jna.jar's path. Thanks!
Extract the com/sun/jna/linux-arm/libjnidispatch.so from the jar file
put the .so file in the following directory (when using android studio): yourproject\app\src\main\jniLibs\armeabi-v7a\libjnidispatch.so
And also please note that linux architecture != android architecture (google uses a different c library (bionic), which is a different one than the normal linux distributions)
For all architectures see:
https://github.com/java-native-access/jna/tree/master/lib/native
Which version of JNA do you use? (There was a bug in JNA 4.2.2/4.3.0 which might also be a cause)
Related
I have been working on creating a simple Java desktop app using the RESTful API for Business Objects and have run into an issue. Whenever I run my app in Eclipse in works fine; whenever I export it as a 'Runnable Jar' and select the Library handling option 'Package required libraries into generated JAR' it works fine. However, whenever I try to export it using the Library handling option 'Extract required libraries into generated JAR' I get the following error after running the app:
java.lang.NoClassDefFoundError: Could not initialize class com.businessobjects.bcm.BCM
I have the 'bcm.jar' file added under a 'res' Source Folder and have it added to the Build Path. At one point I added all the JARs under the 'SAP BusinessObjects' java folder, and external folder, but it still throws the error. The problem stems from this line of code:
enterpriseSession = CrystalEnterprise.getSessionMgr().logon(userID, password, CMS, auth);
Would anyone know why I am getting said error? I really want to use the Extract option as it will improve performance as my app becomes larger. Any help resolving this issue would be greatly appreciated :)
EDIT: I would be happy to provide clarification or further detail upon request!
Seems this was introduced in SP04 and SAP has no intent of fixing it as the RESTful API wasn't designed to be used with Desktop apps.
Have you included the cryptojFIPS.jar? Leaving it out can cause the error.
I am trying to deploy my application that invokes native calls using JNA library, but I get the following exception.
Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'myCustomDLL': Native library (win32-x86-64/myCustomDLL.dll) not found in resource path ([myproject/target/classes/, ...some jars...])
What do I need to do in order to invoke the function correctly?
Any help much appreciated
You must put your dll library (with native code) on application java.library.path.
See :
http://examples.javacodegeeks.com/java-basics/java-library-path-what-is-it-and-how-to-use/
Edit:
Post your project layout here. And how you run your app.
Check whether the DLL is executable.
Check the dependant DLLs are all executable.
With windows explorer, right click on DLL -> property -> security and verify execution rights.
Actually I found the answer to this. Basically, I needed to install Microsoft Visual C++ Redistributable package to install all the necessary DLLs needed for JNA to work. Thanks for other responses to this question.
Update: The problem was solved with the help of MathWorks. I've published the answer below.
I need to control a program (Zemax) from Matlab. Unfortunately, Zemax only supports DDE for such control, which Matlab does not support any more. It works, but stops working on 64 bit platform after a few (presumable 63) DDE calls.
I wonder if there are working solutions. I could probably program a DLL with correct DDE support and then use DDE in Matlab via this DLL. This is a major effort for me. A more suitable solution would be to use Java DDE methods. Following another post here, I've discovered the JDDE library. However I cannot make it work: Even if I am in the directory with the DLL and JAR files, executing
import pretty-tools.JDDE-2.0.3.*
works fine but calling
a = com.pretty_tools.dde.client.DDEClientConversation()
afterwards (as done here) results in
Undefined variable "com" or class "com.pretty_tools.dde.client.DDEClientConversation".
I have very limited writing privileges on my PC, so I have added the javaclasspath.txt file with the jar/dll location to the directory indicated by prefdir. The file looks like this:
C:\Users\xxxxxxxx\Documents\matlab toolbox\jdde\pretty-tools-JDDE-2.0.3.jar
Calling javaclasspath shows a long listing with the last lines being:
...
C:\Program Files\MATLAB\R2012b\java\jarext\webservices\ws_client_core\mw-service-client-core.jar
C:\Users\kkarapet\Documents\matlab toolbox\jdde\pretty-tools-JDDE-2.0.3.jar
DYNAMIC JAVA PATH
<empty>
So path seems to be set correctly. What am I doing wrong?
With the help of MathWorks support, I've found the answer. Here is how to make JDDE work with Matlab 2012b, without admin privileges:
Download and unpack JDDE files (DLLs and JAR) into some folder. Let's say it's $path-to-jdde$\.
In Matlab, type prefdir. Open the resulting directory and create two files there, javaclasspath.txt and javalibrarypath.txt.
In javaclasspath.txt, add $path-to-jdde$\pretty-tools-JDDE-2.0.3.jar.
In javalibrarypath.txt, add $path-to-jdde$\.
Restart Matlab.
Now call ddeConv = com.pretty_tools.dde.client.DDEClientConversation; and start using the created object as described in JavaDoc. E.g. to connect to Zemax, run Zemax and then in call ddeConv.connect('Zemax', 'abc').
Step 2 above can only be done starting Matlab version R2012b. With an older version, if you have the write rights on the Matlab installation directory, you should be able to replace step 2 by editing the files librarypath.txt and classpath.txt in $MATLABROOT$\toolbox\local. I could not verify it so if you confirm it please let me know in the comment below.
I'm having this issue with an app I have written for a Scanner running windows mobile 5.0. I have no idea what it means, can anyone with some Java Cre-Me, windows mobile experience lend some assistance please??
Error given on execution:
java.lang.UnsatisfiedLinkError: no SymbolJavaApi in java.library.path
at java.lang.ClassLoader.loadLibraryInternal()
at java.lang.ClassLoader.loadLibrary()
at java.lang.Runtime.loadLibrary0()
at java.lang.System.loadLibrary()
at
at com.vmt.plugins.symbol.barcodescanner.services.ScannerImplementation.read()
at com.vmt.plugins.symbol.barcodescanner.ScannerPlugin.invoke()
at ScannerTest.startScanning()
at ScannerTest.createwindow()
at ScannerTest.main()
For UnsatisfiedLinkError, the JDK states:
Thrown if the Java Virtual Machine cannot find an appropriate
native-language definition of a method declared native.
That means that there is a method inside ScannerImplementation.read() that is a native call definition that it can't in the java.library.path or any system defined libraries.
What this means is that the DLL that is needed for your ScannerImplementation isn't registered in the Java LIB path and thus the JVM can't do a native call.
I hope this helps.
The Java class loader tries to access the Symbol API but can not find the required libraries in the given library path.
On a desktop system I'd say you need:
Either extend the class path accordingly or
Copy missing external DLLs to the path where your application resides
I'm sure that Symbol/Motorola has some examples where you can see how to do that - maybe you need to install the classes to the device first using a CAB file.
I'm coming from a .NET background and for that, there's a Symbol API CAB file which installs required DLLs to the device.
I have a pci-modem in my laptop and I tried to run a program that opens the port and configures it.I get an excepcion while doing it, I think that it can't see the port, even though it is on COM3. Is there any way of doing it in java?
The error I get is noClassDefFoundError. It says the SerialPortEventListener class isn't found. I'm using rxtxcomm. I tried using javax.comm but it doesn't find the port either.
Thanks a lot
A NoClassDefFoundError indicates that you're missing a JAR file from your classpath, specifically the one that is holding SerialPortEventListener class. Check your classpath.
Have you followed the installation instructions for rxtxcomm ? Note you have to handle a library and a jar file. You need to specify a system library path for the native component.
You may find that you get the 'no class def found' if the appropriate .jar is found, but it can't find the corresponding native library to load.