Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » UnsatisfiedLinkError(Eclipse can't run the program, while javac/java can)
UnsatisfiedLinkError [message #725504] Thu, 15 September 2011 01:05 Go to next message
wilt is currently offline wiltFriend
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 #725530 is a reply to message #725504] Thu, 15 September 2011 06:05 Go to previous messageGo to next message
Satyam Kandula is currently offline Satyam KandulaFriend
Messages: 444
Registered: July 2009
Senior Member
You could add -Djava.library.path it as a VM argument in the launch configuration or set the native library as specified in http://www.eclipsezone.com/eclipse/forums/t49342.html
Re: UnsatisfiedLinkError [message #725556 is a reply to message #725530] Thu, 15 September 2011 07:30 Go to previous messageGo to next message
wilt is currently offline wiltFriend
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 Go to previous messageGo to next message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

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 Go to previous messageGo to next message
wilt is currently offline wiltFriend
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 Go to previous messageGo to next message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

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
Re: UnsatisfiedLinkError [message #725751 is a reply to message #725708] Thu, 15 September 2011 16:40 Go to previous messageGo to next message
wilt is currently offline wiltFriend
Messages: 4
Registered: September 2011
Junior Member
Going to properties -> java build path -> library trying to load -> jar file -> native library location and changing it to be

/usr/lib/jni

results in the following execution:

PATH : /usr/lib/jni
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:19)

If I try the same thing from the command line, I get:

java -Djava.library.path=/usr/lib/jni all.LpTest
PATH : /usr/lib/jni
this worked

The program is basically the same was it was, except on success it just prints, "this worked".

Is there any way to figure out what Eclipse is sending to the jvm so I can try and reproduce the issue on the command line?
Re: UnsatisfiedLinkError [message #726140 is a reply to message #725751] Fri, 16 September 2011 16:28 Go to previous messageGo to next message
David Wegener is currently offline David WegenerFriend
Messages: 1445
Registered: July 2009
Senior Member
First I want to make sure that you know there is a difference between java.library.path and the PATH environment variable. These aren't the same thing. Your output shows PATH. If you are printing the PATH environment variable, then this is not what you want. You need to print out the java.library.path System variable.

Eclipse runs Java projects by launching an external process that runs the java command the same as you would from the command line. You can find the command line used to launch the application by opening up the Debug perspective, right clicking on the process in the Debug view, and selecting properties. The shows the actual command line used to run the application.

You may want to check the working directory the application runs in. This can effect the locating of resources including libraries. You can change the working directory where Eclipse launches your application on the Arguments tab of the Launch Config.
Re: UnsatisfiedLinkError [message #990680 is a reply to message #725751] Thu, 13 December 2012 18:49 Go to previous messageGo to next message
Nitish Rawat is currently offline Nitish RawatFriend
Messages: 1
Registered: December 2012
Junior Member
Could you run the program in eclipse finally?
Re: UnsatisfiedLinkError [message #1718683 is a reply to message #725504] Tue, 29 December 2015 08:30 Go to previous message
Frans Van Assche is currently offline Frans Van AsscheFriend
Messages: 1
Registered: December 2015
Junior Member
I had the same problem under Windows 10 (64 bit) using Eclipse Mars (64 bit).
I eventually got it running with the following steps:

1. Download lp_solve_5.5.2.0_dev_win64.zip from sourceforge.net/projects/lpsolve/files/lpsolve/5.5.2.0/ and install it into a directory, e.g. LpSolve.

2. Download lp_solve_5.5.2.0_java.zip from the same url and copy lpsolve55j.dll from \lib\win64\ to your LpSolve directory created in step 1; i.e. the directory that contains lpsolve55.dll.

3. Extract lpsolve55j.jar from the zip file downloaded in step 2 and place it somewhere (e.g. in your workspace or lpsolve directory). Include this jar as an external library in the build path of your eclipse project (using the properties of your project).

4. Set the PATH environment variable under windows pointing also to your LpSolve directory created in step 1.

5. Restart Eclipse, as it will take into account the changed PATH environment variable only after restart.

Important points to remember:
1. Ensure you have the 64 versions of lpsolve55.dll and lpsolve55j.dll if you are using a 64bit version of eclipse.
2. Although the error message refers to 'java.library.path', it is the PATH environment variable that should be set. There are other ways to do it but setting the PATH environment variable is the quickest and easiest.
3. It is important to download the development version of lpsolve that includes lpsolve55.dll.


Previous Topic:Build output
Next Topic:Uninstall Eclipse Mars
Goto Forum:
  


Current Time: Fri Apr 19 02:30:39 GMT 2024

Powered by FUDForum. Page generated in 0.04338 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top