Eclipse / Java path problems - java

I'm currently following the third tutorial listed here: here
where I'm trying to compile some matlab code into Java classes. Creating a project in eclipse, and correctly linking the libraries (exactly how its done in the tutorial). Everything actually compiles, but when I run the program I get an Unsatisfied Link error.
Exception in thread "main" java.lang.UnsatisfiedLinkError: Can't load library: C:\Program Files\MATLAB\R2009b\bin\win32\BuilderJABootstrap.dll
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.load0(Unknown Source)
at java.lang.System.load(Unknown Source)
at com.mathworks.toolbox.javabuilder.internal.MWMCR.<clinit>(MWMCR.java:1571)
at com.demo.DemoMCRFactory.<clinit>(DemoMCRFactory.java:100)
at com.demo.MLTestClass.<init>(MLTestClass.java:62)
at Driver.main(Driver.java:16)
The troubling part is the Can't load library: as the path provided '\win32' is not a legitimate path on my computer as I have a 64 bit machine, so the dll is located at \win64. However, I've triple checked all my Environmental variables and am kind of stuck. Could I be using a 64-bit version of matlab, with a 32-bit library?
Thanks!

ChrisH's solution was it

Related

Unsatisfied Linker Error : library file not found

I am writing test cases for a class that calls the constructor of another class that has a static block that loads a c++ library,
static
{
System.loadLibrary("PixelProxy_jni");
}
I have specified the library path as,
-Djava.libarary.path=C:\Users\Desktop\libPixelProxy_jni.so
in the vm arguments in eclipse, but still it doesn't work.
Please help me find a solution for this
stack trace
java.lang.UnsatisfiedLinkError: no PixelProxy_jni 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)
at com.XrayPixelProxyInputStream.<clinit>(XrayPixelProxyInputStream.java:36)
at com.RadImageReader.readImage(RadImageReader.java:57)
at servicedisplay.ServiceImageDisplayer.showImage(ServiceImageDisplayer.java:124)
at servicedisplay.test1.ServiceImageDisplayerTest.testShowImageStringIntIntIntIntIntInt(ServiceImageDisplayerTest.java:95)
From that file path, it looks like you're on windows, which means that loadLibrary will not look for a file named libPixelProxy_jni.so, it will look for a file named PixelProxy_jni.dll. (You can find out exactly what it will look for by using System.mapLibraryName.)
You can either find a .dll of the library, compile one yourself, or try System.load, which allows you to load a native library from an absolute path:
System.load("C:\Users\Desktop\libPixelProxy_jni.so");
But that will only work if the library was actually compiled for windows.

GLPK java java.lang.UnsatisfiedLinkError: Can't find dependent libraries

The dynamic link library for GLPK for Java could not be loaded.
Consider using
java -Djava.library.path=
The current value of system property java.library.path is:
\\MILP\lib\glpk-4.55\w64
Exception in thread "main" java.lang.UnsatisfiedLinkError:
\\MILP\lib\glpk-4.55\w64\glpk_4_55_java.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.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at org.gnu.glpk.GLPKJNI.<clinit>(GLPKJNI.java:24)
at org.gnu.glpk.GLPK.glp_version(GLPK.java:2259)
at TestMain.main(TestMain.java:7)
I have added the correct JAR file
I have given the correct native path for the library
Still the problem persists,
One doubt I have is that the \MILP\lib\glpk-4.55\w64\glpk_4_55_java.dll file is flawed. I checked it using dependencyWalker there it shows some warnings
Error: At least one module has an unresolved import due to a missing export function in an implicitly dependent module.
Error: Modules with different CPU types were found.
Any leads would be appreciated
I also faced same issue. I copied glpk_4_55.dll and glpk_4_55_java.dll to C:\Windows\System32 and Everything works fine for me.
You can add the C:\Program Files\GLPK\glpk-4.55\w64 folder to your PATH environment variable
or
copy the glpk_4_55.dll and glpk_4_55_java.dll to C:\Windows\System32 as suggested by Pradeepb

Cannot find dependent libraries for openni2.jni - OpenNI 2, Java, Kinect For Windows

I'm trying to get started with OpenNI 2 using Java and the Kinect for Windows Sensor (Not the Xbox version) yet am experiencing significant problems.
While the sample SimpleViewer program functions correctly, I cannot get the Java equivalent to run (SimpleViewer.java). It successfully compiles after I added org.openni.jar to my classpath, yet upon attempting to run the program I am faced with the following error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\Program Files\Open
NI2\Tools\OpenNI2.jni.dll: Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary1(Unknown Source)
at java.lang.ClassLoader.loadLibrary0(Unknown Source)
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at org.openni.NativeMethods.<clinit>(NativeMethods.java:44)
at org.openni.OpenNI.initialize(OpenNI.java:113)
at OpenNITest.SimpleViewerApplication.main(SimpleViewerApplication.java:
190)
After reading up on similar problems I attempted the following to try to resolve the problem, having thrown pretty much every library I could find in OpenNI into the Tools folder (Contents of Lib and Tools/OpenNI2/Drivers) in case it wasn't finding the correct dependencies.
java -Djava.library.path="C:/Program Files/OpenNI2/Tools" OpenNITest.SimpleViewerApplication
I'm running Windows 7 Enterprise Edition, Java 1.7.0_21 and the latest version of OpenNI 2. OpenNITest is the name of the folder and package I put the sample application in.
If anyone has any advice for trying to resolve this problem it would be greatly appreciated as I've been at it for 3 hours yet am still failing miserably at resolving it.
Thanks!
Finally got this working, add the following and load the library OpenNI2.dll (directory to wherever it is on your machine or use loadLibrary() if you want a relative path) and all will be merry, just wish OpenNI had included an actually working Java sample!
static {
try {
System.load("C:\\Program Files\\OpenNI2\\Tools\\OpenNI2.dll");
}
catch (Exception e)
{
e.printStackTrace();
}
}

How to proceed with this exception java.lang.UnsatisfiedLinkError?

this example of code generates an exception :
Exception in thread "main" java.lang.UnsatisfiedLinkError: no swt-win32-3235 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)
at org.eclipse.swt.internal.Library.loadLibrary(Library.java:134)
at org.eclipse.swt.internal.win32.OS.<clinit>(OS.java:18)
at org.eclipse.swt.widgets.Display.<clinit>(Display.java:125)
at Snippet262.main(Snippet262.java:34)
What does it mean please and how can I resolve it ?
Thank you
You need to add swt-win32-3235.dll to the library_path in your app. By default library_path equals to working dir (".") of your app. Or you may specify path to library_path in vm argument -Djava.library.path=path
So,
1.Check existing swt-win32-3235.dll in your library_path.
2. Check correct definition of library_path property.
This is a runtime exception, that means that the code uses shared library's (using jni probably) which it cannot load.
here you have two options:
the shared library is not installed on you system.
the path to the shared lib is not included in the LD_LIBRARY_PATH (on linux, not sure how it called on windows)
I got the error while running my application. The exception was
java.lang.UnsatisfiedLinkError exception :
SK.gnome.twain.TwainManager.initialize(I[B[BZ)V
I fix it in eclipse as below step, Windows>Preferences>Java>Install JREs>check jre6-32 (check the appropriate versions of jre that you have install in your system).

com4j on Windows 64 bit

I've downloaded the latest com4j jars and I'm trying to run through the most simple of their examples.
I'm on Windows 7 64 bit and using a 64 bit JVM.
When I run the command (from the com4j tutorial):
java -jar tlbimp.jar -o wsh -p test.wsh %WINDIR%\system32\wshom.ocx
I get:
Exception in thread "main" java.lang.UnsatisfiedLinkError: com4j-amd64.dll: %1 is
not a valid Win32 application
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 com4j.COM4J.loadNativeLibrary(COM4J.java:569)
at com4j.COM4J.<clinit>(COM4J.java:522)
at com4j.tlbimp.driver.Lib.getLibid(Lib.java:90)
at com4j.tlbimp.driver.Driver.addLib(Driver.java:38)
at com4j.tlbimp.driver.Main.doMain(Main.java:123)
at com4j.tlbimp.driver.Main.main(Main.java:56)
Exception in thread "Com4J shutdown hook" java.lang.NoClassDefFoundError: Could
not initialize class com4j.COM4J
at com4j.COM4J$3.run(COM4J.java:476)
The java code extracts "com4j-amd64.dll" next to the jar.
The latest version has just been released:
http://kohsuke.org/2012/04/27/com4j-updates/
https://github.com/kohsuke/com4j/downloads
Using this one solved all my problems.
You have two options:
Download and use the full latest version (located here:
https://github.com/kohsuke/com4j/downloads)
Extract the latest com4j-amd64.dll from the most recent version
Download the latest version (located here: https://github.com/kohsuke/com4j/downloads).
Open up the com4j.jar with your favorite zip utility (read 7zip)
Extract com4j.jar\com4j\com4j-x64.dll to the base directory of your application
(optional) Register the dll using REGSVR32 <path to dll>\com4j-x64.dll
I had a similar result at first. I found the com4j-amd64.dll that is produced by com4j is empty. The remedy is to extract the file from the com4j jar file, and put it in the relevant directory by manual action. Com4j will then not auto-produce the file since it is already there. So check if the file is empty as a first step -Carl

Categories

Resources