Eclipse (Helios) fails to load DLL - java

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

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

How could set the java.library.path in Linux from I am trying JNI

I follow this JNI ref to call c function from java.
In final step, I got follow error msg after I type java hellojni :
Exception in thread "main" java.lang.UnsatisfiedLinkError: no helloJni in
java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1864)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at HelloJni.(HelloJni.java:13)
I try to set up the java.library.path, so I type java -Djava.library.path=. HelloJni
But this not works for me, I still got same error message.
Also, I try export LD_LIBRARY_PATH = $LD_LIBRARY_PATH:/sybase/IQ-16_0/jim_samples/udf/hellojni, but is still no work.
This seems like path issue, where your libhellojni.so is not found in "sybase/IQ-16_0/jim_samples/udf/hellojni" directory.
Remember 'lib' prefix is important in your xxx.so file (if you are running this in Linux), just hellojni.so will not work.

JNA Different behavior on pcs

i have a java program that works with jna and loads a dll. On my develop computer the program runs without problems. But when i run the program on a different pc i get the error that the program cant find the dependet dlls. But my dll depends only on one dll an this dll is inside the same folder.
I run the program as a jar on Windows 7. Dependency walker shows on both pc the same dependecies.
I dont know what the problem or the difference between those computers is.
Why cant the program load the dll?
Error Message:
Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\THZ-standalone\Dlls\BladeTileLocator.dll: Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(Unknown Source)
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.load0(Unknown Source)
at java.lang.System.load(Unknown Source)
at de.thz.cameracontrol.utils.Utils.loadLibrary(Utils.java:169)
at de.thz.cameracontrol.server.Server.<init>(Server.java:124)
at de.thz.cameracontrol.server.Server.main(Server.java:165)
I call the program with java -jar Program.jar.
The dlls are saved in a folder (this folder is in the same folder as the java program).
Here is the method for the libray loading:
public static Object loadLibrary(String libraryName, Class<?> clazz) {
final String userDir = System.getProperty("user.dir");
final String filePathToUse = userDir + "\\" + DLL_PATH;
System.setProperty("jna.platform.library.path", filePathToUse);
System.load(filePathToUse + libraryName + ".dll");
return Native.loadLibrary(libraryName, clazz);
// return Native.loadLibrary(libraryName, clazz);
}
I use the statement System.load(filePathToUse + libraryName + ".dll"); for better error messages.
The origin of the problem was a wrong name for the JNA library path system property. The right name is jna.library.path.
1) Start your application with -Djna.debug_load=true -Djna.debug_load.jna=true to get some information where the JNA library is looking for the DLL.
2) Shouldn't it be rather jna.library.path instead of jna.platform.library.path.3) Maybe you are mixing 32bit/64bit DLL/JVM?

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.

LibraryNotFoundException while running java code that invokes dlls

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.

Categories