Home » Newcomers » Newcomers » UnsatisfiedLinkError(Eclipse can't run the program, while javac/java can)
UnsatisfiedLinkError [message #725504] |
Thu, 15 September 2011 01:05 |
wilt Messages: 4 Registered: September 2011 |
Junior Member |
|
|
If I compile my program doing this:
javac LpTest.java
then run it using:
java all.LpTest
It works fine.
Eclipse appears to have "successfully" compiled the program in that it didn't produce anything that looks like errors, but when I try to run the program I get the following error:
PATH : /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/server:/usr/lib/jvm/java-6-openjdk/jre/lib/amd64:/usr/lib/jvm/java-6-openjdk/jre/../lib/amd64:/usr/lib/xulrunner-1.9.2.22:/usr/java/packages/lib/amd64:/usr/lib/jni:/lib:/usr/lib
CLASSPATH : /home/aifs2/cmo66/cjava/test/bin:/usr/share/java/lpsolve55j.jar
Exception in thread "main" java.lang.UnsatisfiedLinkError: no lpsolve55j in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1681)
at java.lang.Runtime.loadLibrary0(Runtime.java:840)
at java.lang.System.loadLibrary(System.java:1047)
at lpsolve.LpSolve.<clinit>(LpSolve.java:275)
at all.LpTest.main(LpTest.java:18)
For the curious, the entire contents of the program is included as an attachment. Note that it uses the lpsolve library.
It uses a shared object file, but the shared object file is in one of the directories in the java.library.path variable. In addition to that, the file is present, works, etc. because the java executable is able to make the thing run, but something about Eclipse is not working correctly.
Does anyone know why this is happening, or what settings in Eclipse have to be changed?
Thank you very much.
-
Attachment: LpTest.java
(Size: 1.15KB, Downloaded 531 times)
[Updated on: Thu, 15 September 2011 01:08] Report message to a moderator
|
|
| |
Re: UnsatisfiedLinkError [message #725556 is a reply to message #725530] |
Thu, 15 September 2011 07:30 |
wilt Messages: 4 Registered: September 2011 |
Junior Member |
|
|
The java.library.path variable, which was printed out, already contains the path to the libraries in question. This can be seen in the output of the program, where PATH: ... has a whole bunch of directories, one of which is /usr/lib/jni which is where the .so files it is looking for are located. I think this is a problem with Eclipse, because the .so files are there, and the command line java is able to interact with them, so there is nothing wrong with the .so files, the path, etc.
In addition to that, I have tried feeding the -Djava.library.path=/usr/lib/jni as an argument to the JVM as you suggested, and that didn't work either. I also tried modifying the path to the library, and that didn't work either. What I get when I try either of those choices is the java.library.path variable prints as whatever I said to look for libraries in, but it still can't load the files when run through Eclipse.
|
|
|
Re: UnsatisfiedLinkError [message #725668 is a reply to message #725556] |
Thu, 15 September 2011 13:35 |
|
On 15-Sep-11 01:30, wilt wrote:
> The java.library.path variable, which was printed out, already contains
> the path to the libraries in question. This can be seen in the output of
> the program, where PATH: ... has a whole bunch of directories, one of
> which is /usr/lib/jni which is where the .so files it is looking for are
> located. I think this is a problem with Eclipse, because the .so files
> are there, and the command line java is able to interact with them, so
> there is nothing wrong with the .so files, the path, etc.
> In addition to that, I have tried feeding the
> -Djava.library.path=/usr/lib/jni as an argument to the JVM as you
> suggested, and that didn't work either. I also tried modifying the path
> to the library, and that didn't work either. What I get when I try
> either of those choices is the java.library.path variable prints as
> whatever I said to look for libraries in, but it still can't load the
> files when run through Eclipse.
Perhaps this comment helps?
http://www.javahotchocolate.com/tutorials/jni.html#a_native
|
|
|
Re: UnsatisfiedLinkError [message #725700 is a reply to message #725668] |
Thu, 15 September 2011 14:43 |
wilt Messages: 4 Registered: September 2011 |
Junior Member |
|
|
The problem isn't that the jvm can't find the .so per se. Examining the output of the program, we can see that the path for looking for .so files does indeed contain the directory it needs to contain, which implies that adding to or overwriting the java.library.path variable is not needed, because that variable already contains the path it needs to contain.
The problem is that when run through Eclipse, the jvm doesn't find the .so files it needs to run, while when run not through Eclipse, the jvm does manage to find the files in question, which demonstrates, that the shared object files are present, in good working order, etc. It's getting to the point where I suspect this may just be a bug in Eclipse.
|
|
|
Re: UnsatisfiedLinkError [message #725708 is a reply to message #725700] |
Thu, 15 September 2011 14:48 |
|
On 15-Sep-11 08:43, wilt wrote:
> The problem isn't that the jvm can't find the .so per se. Examining the
> output of the program, we can see that the path for looking for .so
> files does indeed contain the directory it needs to contain, which
> implies that adding to or overwriting the java.library.path variable is
> not needed, because that variable already contains the path it needs to
> contain.
>
> The problem is that when run through Eclipse, the jvm doesn't find the
> .so files it needs to run, while when run not through Eclipse, the jvm
> does manage to find the files in question, which demonstrates, that the
> shared object files are present, in good working order, etc. It's
> getting to the point where I suspect this may just be a bug in Eclipse.
Perhaps, indeed.
I wrote that article a good 18 months ago and what you describe is
evocative of my experience; the paragraph I referred you to is how I
solved it. I was using Galileo at the time.
Best of luck,
Russ
|
|
| | | | |
Goto Forum:
Current Time: Fri Apr 19 02:30:39 GMT 2024
Powered by FUDForum. Page generated in 0.04338 seconds
|