LibraryNotFoundException while running java code that invokes dlls - java

I have written a code that requires 2 dll's at runtime.I have those dll files in C:\Program Files\Java\jdk1.6.0_01\jre\bin.
I have set the environment variable PATH accordingly.
It compiled successfully and then while running it gives the following error:
Exception in thread "main" java.lang.ExceptionInInitializerError
at teamdev.jxcapture.Capture.captureActiveWindow(Unknown Source)
at ppb.activewindow.execute(activewindow.java:24)
at ppb.activewindow.main(activewindow.java:68)
Caused by: com.jniwrapper.LibraryNotFoundException: Cannot find JNIWrapper nativ
e library (jniwrap.dll) in java.library.path: C:\Program Files\Java\jdk1.6.0_01\
jre\bin\jniwrap.dll
Could anybody please help me to resolve this problem?

The value of java.library.path should be the directory containing the DLLs, not the filename of the DLLs themselves. It looks like your java.library.path is set to
C:\Program Files\Java\jdk1.6.0_01\jre\bin\jniwrap.dll
instead of
C:\Program Files\Java\jdk1.6.0_01\jre\bin

It looks like the DLL is not being found on the Java Library Path. See this - http://www.inonit.com/cygwin/jni/helloWorld/load.html
Try moving JDK to a path without spaces.

Related

java.lang.UnsatisfiedLinkError: ars3wapi32 still after updating path variable

I am trying to set up On Demand Server in my local machine and when ever I am deploying the application on tomcat server I am getting below error message on browser. I have updated the PATH variable also.
root cause
java.lang.UnsatisfiedLinkError: ars3wapi32 (Not found in java.library.path)
java.lang.ClassLoader.loadLibraryWithPath(ClassLoader.java:1007)
java.lang.ClassLoader.loadLibraryWithClassLoader(ClassLoader.java:971)
java.lang.System.loadLibrary(System.java:470)
com.ibm.edms.od.ArsWWWInterface.<clinit>(ArsWWWInterface.java:15)
java.lang.J9VMInternals.initializeImpl(Native Method)
java.lang.J9VMInternals.initialize(J9VMInternals.java:200)
com.ibm.edms.od.ODServer.<init>(ODServer.java:45)
com.ibm.edms.od.ODServer.<init>(ODServer.java:61)
com.uklife.web.ondemand.utils.DownloadUtils.getAFPDocumentFromOnDemand(DownloadUtils.java:80)
com.uklife.web.ondemand.utils.Utils.getDocument(Utils.java:288)
com.uklife.web.ondemand.servlet.OnDemandDocAccess.doGet(OnDemandDocAccess.java:81)
javax.servlet.http.HttpServlet.s`enter code here`ervice(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722
)
Here is a guide the solution (for Windows and OnDemand V9.5).
First of all, you need to install ODWEK on the machine where you want to run your java app. Please install in the default folder, this whole thing is tricky enough as it is...
Set the environment variable "PATH" in Windows, add "C:\Program Files\IBM\OnDemand\V9.5\bin"
Set CLASSPATH in your development environment - point out the ODApi.jar file and ALSO point "Native library..." to the \bin folder above. (You can also call the program and setting the CLASSPATH in the call as a parameter: -Djava.library.path="C:\Program Files\IBM\OnDemand\V9.5\www\api\ODapi.jar"
Copy the file ars3wapi64.dll from C:\Program Files\IBM\V9.5\www to C:\Program Files\IBM\OnDemand\V9.5\bin
Ensure that all of these files are in the bin-catalog above:
**ars3wapi64.dll**
icudt53.dll
icuin53.dll
icuio53.dll
icule53.dll
iculx53.dll
icuuc53.dll
arsgsk64.dll
If you are getting the error "java.lang.UnsatisfiedLinkError: ars3wapi32 (Not found in java.library.path)" one of the above is most likely incorrect.
OR you could be using different versions of ODWEK and OnDemand.
More on how to set CLASSPATH in Eclipse: How to set the java.library.path from Eclipse

Can't find/load swt-gtk

I'm trying to run an internal web browser using JWebBrowser. When I run the application in Netbeans environment it works perfectly. However, when I build the project and run the jar file I'm getting the following error:
NativeSwing[1]: Exception in thread "main" java.lang.UnsatisfiedLinkError: Could
not load SWT library. Reasons:
NativeSwing[1]: no swt-gtk-3721 in java.library.path
NativeSwing[1]: no swt-gtk in java.library.path
NativeSwing[1]: Can't load library: C:\Users\CCS.swt\lib\win32\amd64\swt-gtk-3721.dll
NativeSwing[1]: Can't load library: C:\Users\CCS.swt\lib\win32\amd64\swt-gtk.dll
I'm including the following libraries to the project:
DJNativeSwing.jar
DJNativeSwing-SWT.jar
DJNativeSwing-SWTAPI.jar
DJNativeSwing-SWTCore.jar
MozillaInterfaces-1.8.1.3.jar
swt.jar (version 3.7M5 for 64 bits.)
jna_WindowUtils.jar
jna-3.2.4.jar
and they're referenced by Manifest.MF by this way
Class-Path: lib/DJNativeSwing-SWT.jar lib/DJNativeSwing-SWTAPI.jar lib
/DJNativeSwing-SWTCore.jar lib/MozillaInterfaces-1.8.1.3.jar lib/DJNa
tiveSwing.jar lib/swt.jar lib/jna-3.2.4.jar lib/jna_WindowUtils.jar
What am I doing wrong?
Thank you.
You need to specify the java.library.path in the java command and aim it at the path to your .dll files. For example,
java -Djava.library.path=lib -cp ...
Ok, I found the solution. The problem was about the dll generation. I was using 3.7m5 version, I downloaded a previous version (3.7) and the application ran properly.
Thank you for your help.
Regards.

Getting Java3D to work in Eclipse

I am trying to get J3D to work in Eclipse and have read forum after forum but can't seem to fix my problem. I am using ubuntu 11.10
I have done this:
0) unzipped j3d-1_5_2-linux-i586 in home/j3d directory then added i386 folder to usr/lib/jvm/java-6-openjdkjre/lib/i386
1) Window--> Preferences--> User Libraries --> New and added the three .jar files (j3dcore.jar, j3dutils.jar, vecmath.core)
2) Added a native library location to point to usr/lib/jvm/java-6-openjdkjre/lib/i386 where the .so files are
Some sources say try adding the .jar files to your Classpath Variable which didn't fix the problem for me.
I keep getting
Exception in thread "main" java.lang.UnsatisfiedLinkError: /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/libj3dcore-ogl.so: /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/libj3dcore-ogl.so: wrong ELF class: ELFCLASS32 (Possible cause: architecture word width mismatch)
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1750)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1667)
at java.lang.Runtime.loadLibrary0(Runtime.java:840)
at java.lang.System.loadLibrary(System.java:1047)
at javax.media.j3d.NativePipeline$1.run(NativePipeline.java:231)
at java.security.AccessController.doPrivileged(Native Method)
at javax.media.j3d.NativePipeline.loadLibrary(NativePipeline.java:200)
at javax.media.j3d.NativePipeline.loadLibraries(NativePipeline.java:157)
at javax.media.j3d.MasterControl.loadLibraries(MasterControl.java:987)
at javax.media.j3d.VirtualUniverse.(VirtualUniverse.java:299)
at Hello3d.(Hello3d.java:13)
at Hello3d.main(Hello3d.java:27)
I had the same problems. Most tutorials tell you to assign an new library, but i mixed the Java3D files with the JDK files and re installed eclipse. If this doesn't work use net Beans.

JPL/SWI Prolog not working

I'm trying to use the SWI-Prolog JPL library, but I'm having problems.
I'm trying to let my Eclipse project access JPL, but when I try to start the program, I get the following error:
Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: no jpl in java.library.path
I copied the jpl.jar into my project directory, and I set it on the build path. Additionally, I pass the following VM arguments:
-Djava.library.path="C:\Program Files\Prolog\bin"
(That's the directory where Prolog was installed).
What am I doing wrong?
EDIT: I don't seem to have the libpl.dll anywhere on my computer. Could this be causing my problem?
The jvm.dll of your running JDK/JRE must be available in your system PATH so that jpl.dll from java.library.path loads properly.
You have to take care to 32 bits / 64 bits consistency between your JPL installation and your running JVM - so do not try any mix.
Here is information from an old installation doc.
For such installation support, you should use the JPL mailing list.
You should set the java.library.path to the folder where the jpl.dll file is located. As far as I know it is the Prolog\bin folder.
A system-wide solution in a Mac environment (SWI-Prolog version 7.1.4 for x86_64-darwin13.1.0) would be to create the following symlink:
ln -s /usr/local/Cellar/swi-prolog/7.1.4/libexec/lib/swipl-7.1.4/lib/x86_64-darwin13.1.0/libjpl.jnilib /Library/Java/Extensions/libjpl.jnilib
Could be rather
ln -s
/Applications/SWI-Prolog.app/Contents/swipl/lib/x86_64-darwin/libjpl.dylib
/Library/Java/Extensions/libjpl.dylib
? (no .inilib was found under darwin folder)
In my case still error on mojave (SWI-Prolog (threaded, 64 bits, version 8.0.2)):
Jan 03, 2020 12:10:55 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [ACTIONS] in context with path [/SVIZ] threw exception [Servlet execution threw an exception] with root cause
java.lang.UnsatisfiedLinkError: /Applications/SWI-Prolog.app/Contents/swipl/lib/x86_64-darwin/libjpl.dylib: dlopen(/Applications/SWI-Prolog.app/Contents/swipl/lib/x86_64-darwin/libjpl.dylib, 1): Library not loaded: #rpath/libswipl.8.dylib
Referenced from: /Applications/SWI-Prolog.app/Contents/swipl/lib/x86_64-darwin/libjpl.dylib
Reason: image not found

Eclipse (Helios) fails to load DLL

My Java program fails with the following error on Windows.
Exception in thread "main" java.lang.UnsatisfiedLinkError: no XSvcSocket in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
I tried different things like
adding the location of DLL to system's path env variable
setting location of DLL explicitly in the program as below
String libpath = System.getProperty("java.library.path");
libpath = "C:\\extlibs;" + libpath;
System.setProperty("java.library.path", libpath);
libpath = System.getProperty("java.library.path");
java.library.path I get see is shown below.
"Lib Path: C:\extlibs;C:\Program Files\Java\jre6\bin;.;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows"
The DLL in question is available in "C:\extlibs". Couple of observation are that when I place the DLL into "C:\Program Files\Java\jre6\bin", my program doesn't crib about the DLL (i.e it loads it) but I have to take care of many other DLLs too.
Can anyone shed some light on this behavior? by the way I am also not able to figure out from where eclipse is picking C:\Program Files\Java\jre6\bin and adding to java.library.path? it's not part of system's path environment variable.
The correct way to add native libraries in eclipse is as shown below. Go to Properties/Java Build Path/Libraries/Expand the jar file for which you want to add the native library/Select Native Library location/Click Edit/Add the DLL

Categories