UnsatisfiedLinkError when compiling with JyMOL

72 views
Skip to first unread message

Jose_Cruz-Toledo

unread,
Nov 3, 2010, 9:01:34 PM11/3/10
to Schrödinger Developer Forum
Hi,

I am getting an UnsatisfiedLinkError when compiling projects that
include jymol-1.0.jar. In eclipse and through the command line. I have
checked that the JAR has been added to the classpath.

javac -classpath myClassPath:jymol-1.0.jar my/java/src*.java

Exception in thread "main" java.lang.UnsatisfiedLinkError: no jymol in
java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1734)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1028)
at com.delsci.jymol.JyMolWrapper.<clinit>(JyMolWrapper.java:119)
at demos.jymol.simple.Simple.<init>(Simple.java:51)
at demos.jymol.simple.Simple.main(Simple.java:151)

Can anybody help me getting my code working?

Jason Vertrees

unread,
Nov 3, 2010, 11:30:08 PM11/3/10
to schrodinger-d...@googlegroups.com
Hi Jose,

It looks like you read the JyMOL documentation and tried this
yourself, so I'm happy to help!

That error means Java cannot find and load the jymol library.  This
can occur when you specify the wrong architecture, the classpath is
wrong, or the jarfile is malformed. My guess is your classpath is
incorrect. I'm not sure how much experience you have with Java, but
the classpaths are an early pitfall for everyone. (If you'd like to
lean more about Java classpaths, see
http://en.wikipedia.org/wiki/Classpath_(Java) and Google for 'java
classpath'.). Let's troubleshoot this.

First, if you typed,


javac -classpath myClassPath:jymol-1.0.jar my/java/src*.java

then you're telling the Java compiler the following:
(1) please compile my Java source code located in "my/java" called
"src*.java" into Java bytecode. The files all match the pattern
"src*.java", so they could be named "src1.java", "src2.java" etc.
(2) everything you need to compile the source files can be found in
the directory called "myClassPath" and in the jar file called
'jymol-1.0.jar", which is in the current directory, and that's
essentially it.

Let's look at a quick example. If your source code really is
"protein.java" in "java/src" and jymol-1.0.jar lives in your "lib"
directory then your command line would be:
javac -classpath lib/jymol-1.0.jar java/src/protein.java

In the documentation, I wrote
javac -classpath yourClassPath:jymol-1.0.jar your/java/src*.java
because if you're a seasoned Java developer the "yourClassPath"
element would actually be a list of directories and jar files with
other components in them. My guess is that if jymol-1.0.jar is in the
current directory, you need to type,
javac -classpath ./jymol-1.0.jar my/java/src*.java

Maybe you did all this correctly, but I made a mistake in packaging
JyMOL--which is very possible. Please report the result of running:
jar tvf jymol-1.0.jar

Last, there's another user of ours who has a page on his experience
with JyMOL in NetBeans; while not Eclipse, his ideas might help you
out:

> Since I am using Netbeans as my  IDE, I have configured  JyMOL API
> with Netbeans. The steps I documented within a dokuwiki.
> (http://140.109.55.41/~px172/JyMOL). My purpose is simple, to share my
> experience with others. If anything of JyMOL I wrote is confidential
> to you or your company, please inform me, I will remove them
> immediately.

Let me know if this helps. You can even send me your code if you want
me to look at it.

Happy hacking!

-- Jason

--
Jason Vertrees, PhD
PyMOL Product Manager
Schrodinger, LLC

(e) Jason.V...@gmail.com
(o) +1 (603) 374-7120

> --
> You received this message because you are subscribed to the Google Groups "Schrödinger Developer Forum" group.
> To post to this group, send email to schrodinger-d...@googlegroups.com.
> To unsubscribe from this group, send email to schrodinger-develop...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/schrodinger-developer-forum?hl=en.
>
>

Jose Miguel Cruz Toledo

unread,
Nov 4, 2010, 7:59:48 PM11/4/10
to schrodinger-d...@googlegroups.com
Jason,

I was able to compile it using javac directly in a command line. However I am still looking for a solution for eclipse. In the mean time here is the output of jar tvf jymol-1.0.jar

I will keep you posted.
Jose

4664 Tue Aug 17 11:57:32 EDT 2010 META-INF/MANIFEST.MF
  4774 Tue Aug 17 16:08:18 EDT 2010 META-INF/JKEYS.SF
  3529 Tue Aug 17 16:08:18 EDT 2010 META-INF/JKEYS.RSA
     0 Sat Aug 14 13:54:30 EDT 2010 META-INF/
  5957 Sat Aug 14 13:54:00 EDT 2010 com/delsci/jymol/JyMolCGO.class
  2260 Sat Aug 14 13:54:00 EDT 2010 com/delsci/jymol/JyMolCGO$Node.class
  3827 Sat Aug 14 13:54:02 EDT 2010 com/delsci/jymol/JyMol.class
  1415 Sat Aug 14 13:54:00 EDT 2010 com/delsci/jymol/JyMolClickConsumer.class
  1036 Sat Aug 14 13:54:00 EDT 2010 com/delsci/jymol/JyMolException.class
   492 Sat Aug 14 13:54:00 EDT 2010 com/delsci/jymol/JyMolGLWrapper.class
   981 Sat Aug 14 13:54:00 EDT 2010 com/delsci/jymol/JyMolImageConsumer.class
   233 Sat Aug 14 13:54:00 EDT 2010 com/delsci/jymol/JyMolJoglWrapper$1.class
  2866 Sat Aug 14 13:54:00 EDT 2010 com/delsci/jymol/JyMolJoglWrapper.class
  2183 Sat Aug 14 13:54:00 EDT 2010 com/delsci/jymol/JyMolJoglWrapper$JyMolGLListener.class
  1084 Sat Aug 14 13:54:00 EDT 2010 com/delsci/jymol/JyMolLock.class
  6475 Sat Aug 14 13:54:00 EDT 2010 com/delsci/jymol/JyMolWrapper.class
 49594 Sat Aug 14 13:54:00 EDT 2010 com/delsci/jymol/JyMolWrapper$Cmd.class
 28215 Sat Aug 14 13:54:00 EDT 2010 com/delsci/jymol/JyMolWrapper$CMol.class
  6790 Sat Aug 14 13:54:00 EDT 2010 com/delsci/jymol/JyMolWrapper$CMolListener.class
  1055 Sat Aug 14 13:54:04 EDT 2010 com/delsci/jymol/test/JyMolExample$1.class
  1205 Sat Aug 14 13:54:04 EDT 2010 com/delsci/jymol/test/JyMolExample$2.class
  1206 Sat Aug 14 13:54:04 EDT 2010 com/delsci/jymol/test/JyMolExample$3.class
  1207 Sat Aug 14 13:54:04 EDT 2010 com/delsci/jymol/test/JyMolExample$4.class
  1142 Sat Aug 14 13:54:04 EDT 2010 com/delsci/jymol/test/JyMolExample$5.class
  1207 Sat Aug 14 13:54:04 EDT 2010 com/delsci/jymol/test/JyMolExample$6.class
  1207 Sat Aug 14 13:54:04 EDT 2010 com/delsci/jymol/test/JyMolExample$7.class
  1369 Sat Aug 14 13:54:04 EDT 2010 com/delsci/jymol/test/JyMolExample$8.class
  1068 Sat Aug 14 13:54:04 EDT 2010 com/delsci/jymol/test/JyMolExample$9.class
  3624 Sat Aug 14 13:54:04 EDT 2010 com/delsci/jymol/test/JyMolExample.class
  6220 Sat Aug 14 13:54:04 EDT 2010 com/delsci/jymol/test/JyMolExample$Ligand1.class
  7783 Sat Aug 14 13:54:04 EDT 2010 com/delsci/jymol/test/JyMolExample$Ligand2.class
  6443 Sat Aug 14 13:54:04 EDT 2010 com/delsci/jymol/test/JyMolExample$Ligand3.class
  2541 Sat Aug 14 13:54:04 EDT 2010 com/delsci/jymol/test/JyMolExample$PdbFromUrl.class
148324 Sat Aug 14 13:54:04 EDT 2010 com/delsci/jymol/test/JyMolExample$Target.class
  1960 Sat Aug 14 13:54:04 EDT 2010 com/delsci/jymol/test/JyMolExample$ToggleAction.class
   719 Sat Aug 14 13:54:06 EDT 2010 com/delsci/jymol/test/JyMolTestApp$1.class
   970 Sat Aug 14 13:54:06 EDT 2010 com/delsci/jymol/test/JyMolTestApp$Burnin$1.class
  1168 Sat Aug 14 13:54:06 EDT 2010 com/delsci/jymol/test/JyMolTestApp$BurninAction.class
  2802 Sat Aug 14 13:54:06 EDT 2010 com/delsci/jymol/test/JyMolTestApp$Burnin$BurninListener.class
  3782 Sat Aug 14 13:54:06 EDT 2010 com/delsci/jymol/test/JyMolTestApp$Burnin.class
   619 Sat Aug 14 13:54:06 EDT 2010 com/delsci/jymol/test/JyMolTestApp$Child.class
  7915 Sat Aug 14 13:54:06 EDT 2010 com/delsci/jymol/test/JyMolTestApp.class
   756 Sat Aug 14 13:54:06 EDT 2010 com/delsci/jymol/test/JyMolTestApp$CountUpdater.class
   983 Sat Aug 14 13:54:06 EDT 2010 com/delsci/jymol/test/JyMolTestApp$DemoGrid$1.class
  1246 Sat Aug 14 13:54:06 EDT 2010 com/delsci/jymol/test/JyMolTestApp$DemoGridAction.class
  2045 Sat Aug 14 13:54:06 EDT 2010 com/delsci/jymol/test/JyMolTestApp$DemoGrid.class
  1159 Sat Aug 14 13:54:06 EDT 2010 com/delsci/jymol/test/JyMolTestApp$ExampleAction.class
  1006 Sat Aug 14 13:54:06 EDT 2010 com/delsci/jymol/test/JyMolTestApp$ExampleFrame$1.class
  1540 Sat Aug 14 13:54:06 EDT 2010 com/delsci/jymol/test/JyMolTestApp$ExampleFrame.class
  1022 Sat Aug 14 13:54:06 EDT 2010 com/delsci/jymol/test/JyMolTestApp$GCAction.class
   830 Sat Aug 14 13:54:06 EDT 2010 com/delsci/jymol/test/JyMolTestApp$QuitAction.class

Jason Vertrees

unread,
Nov 4, 2010, 8:35:58 PM11/4/10
to schrodinger-d...@googlegroups.com
Hi Jose,

Great, good work! I just tried this in Eclipse and I figured it out.
Make a new Java project. Import/include your source files. Add all
the mac/windows/linux jar files that come with jymol. I'm currently
on a Mac, so I included all the Mac-specific jar files. Next, in
Eclipse select,
Project > Properties > Java Build Path > Libraries (tab)
and then expand the jymol-1.0.jar line (added above). Click "native
library location" and select the library in which libjymol.so (for
Linux) jymol.dll (for Windows), and libjymol.jnilib (for Mac) live.
You can choose where to put those files; these libjymol files come
packaged in the JyMOL distribution file.

What you're doing is specifying the "native library location" (the
"-Djava.library.path=." on the command line). Great instructions can
be found here: http://stackoverflow.com/questions/957700/how-to-set-the-java-library-path-from-eclipse.

I'll have limited access to development machines for the next few
days. So, if I don't immediately respond, that's why. When I get
back, I'll make a screencast showing how to use this in Eclipse.

Cheers,

-- Jason

--
Jason Vertrees, PhD
PyMOL Product Manager
Schrodinger, LLC

Jose Miguel Cruz Toledo

unread,
Nov 5, 2010, 11:24:52 AM11/5/10
to schrodinger-d...@googlegroups.com
Jason,

Thank you for your prompt replies! 

So to give you more details, I am running Ubuntu 10.10 on a 64bit machine. I am using the Helios release of Eclipse.
And here is EXACTLY what I have done:

1) create a new Java Project
2) under the src folder create a new package com.dumontierlab.JyMolTest
3) right-click on the package com.dumontierlab.JyMolTest -> import -> File System and point to the directory on my file system where Simple.java is stored (i.e.: ~/Programs/JyMol-1.0/src/demos/jymol/simple) then click on Simple.java and "Finish". [Note: this file has been unaltered from the one I downloaded)
4) Change the package name from com.jymol.simple to com.dumontierlab.JyMolTest
5) Right click on the Project Name -> New -> Folder and create a "lib" folder inside of my project
6) Right click on the "lib" directory -> Import -> File System , then on the next screen I browse to the location of the Jar files on my File System (i.e.: ~/Programs/JyMol-1.0/lib/). Then I select all of the Jars and press Finish.
7) Right click on the Simple.java file created on step (3) -> Build Path-> Configure Build Path , I select the Libraries Tab, then I use the "Add JARs..." button to navigate to the "lib" directory  created inside of my project from step (5) and then select jymol-1.0.jar
8) While still in the Libraries Tab I expand the tree under jymol-1.0.jar and click on "Native library location" -> "Edit"-> "External Folder..." and point to the file system location where the native Jars (~/Programs/JyMOL-1.0/lib) are located.
9) Then I try to run Simple.java and get the following error:
 
Exception in thread "main" java.lang.UnsatisfiedLinkError: no jymol in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1734)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1028)
at com.delsci.jymol.JyMolWrapper.<clinit>(JyMolWrapper.java:119)
at com.dumontierlab.JyMolTest.Simple.<init>(Simple.java:51)
at com.dumontierlab.JyMolTest.Simple.main(Simple.java:151)

I have tried countless variations on the above procedure. For example:

- In step 8 instead of pointing to an "External Folder" I use the "Workspace..." option and point to the "lib" directory create in step (5) that contains all of the JARs but that does not seem to make a difference. 

- I have also tried to add the -Djava.library.path=/home/user/Programs/JyMOL-1.0/lib to the VM arguments under the Arguments tab in the Run Configuration for this project, but this does not make a difference.

I do not what else to try without going insane. I have been using eclipse for a while now, but always using maven (I also tried adding the JyMol Jars to my local repository and that didn't work) for all of my dependencies, so I have never had to deal with these problems.

Any help is appreciated.

Jose

Jose Miguel Cruz Toledo

unread,
Nov 5, 2010, 11:50:25 AM11/5/10
to schrodinger-d...@googlegroups.com
FYI,
I have also tried the same procedure that I described in the previous message on 3 different Ubuntu 64 bit installations (one 10.04, and 2 10.10). Another detail is that I have been using version 1.6.0_22 of Sun's JVM.

Jose

Jose Miguel Cruz Toledo

unread,
Nov 5, 2010, 4:28:21 PM11/5/10
to schrodinger-d...@googlegroups.com
Jason,

I think that I have finally solved my own problem by asking one of my colleagues what to do. What had me terribly confused was the importing of the native libraries into my project. I was incorrectly importing into my project the JARs that contain the necessary libraries to run Simple.java  instead of the actual library (.so) files.

So to clarify things I will now provide a list of detailed steps for any other Eclipse JyMol users out there:

1) create a new Java Project
2) under the src folder create a new package com.foo.JyMolTest

//Import the source code directly from the demos directory
3) right-click on the package com.foo.JyMolTest -> Import -> File System and point to the directory on my file system where the extracted Simple.java is stored (i.e.: /home/user/Programs/JyMol-1.0/src/demos/jymol/simple) then click on Simple.java and "Finish". 
4) Change the package name from demos.jymol.simple to com.foo.JyMolTest

//Import into your project the necessary JARs and library files
5) Right click on the Project Name -> New -> Folder and create a "lib" folder inside of my project
6) Right click on the "lib" directory -> Import -> File System , then on the next screen I browse to the location of the JyMOL Jar files your File System (i.e.: /home/user/Programs/JyMol-1.0/lib/). Then I select the following JARs and press Finish.
- jymol-1.0.jar
- jogl-1.0.jar
- gluegen-rt-1.0.jar
7) Now we need to import the necessary native libraries. In my case I am using a 64bit linux OS therefore I will need to import into the "lib" directory created in step (5) the following .so files
- libjymol.so <- found inside of jymol-1.0-natives-linux-x86_64.jar
- libjogl.so <- found inside of jogl-1.0-natives-linux-x86_64.jar
- libjogl_awt <- found inside of jogl-1.0-natives-linux-x86_64.jar
- libgluegen-rt.so <- found inside of gluegen-rt-1.0-natives-linux-x86_64

//Add the JARs to Simple.java and link them to the native libraries
8) Right click on the Simple.java file created on step (3) -> Build Path-> Configure Build Path , Select the Libraries Tab, then use the "Add JARs..." button to navigate to the "lib" directory  created inside of your project from step (5) and then select jymol-1.0.jar. Repeat this step for jogl-1.0.jar and gluegen-rt-1.0.jar.
9) While still in the Libraries tab expand the tree under jymol-1.0.jar and click on "Native library location" -> "Edit"-> "Workspace..." and point to the "lib" directory inside of your Project. Repeat this step for jogl-1.0.jar and gluegen-rt-1.0.jar.
 
Enjoy!

Jason Vertrees

unread,
Nov 6, 2010, 1:09:53 PM11/6/10
to schrodinger-d...@googlegroups.com
Hi Jose,

I spent the day out of the office so couldn't respond until now. But,
it's nice to see that the problem has taken care of itself in the
meantime.

The JyMOL class calls the following code in the static initializer:

{ ...
loadLibrary("jymol");
... }

which loads the native library for your platform (windows, mac,
linux). So, this now means that Java must be able to find that
library, and it looks in the "java.library.path" for it. Feel free to
ask more questions or brag about what you've done.

I should still make a screencast for new users. Let me know how much
you like using Eclipse for JyMOL development.

Cheers,

-- Jason

--
Jason Vertrees, PhD
PyMOL Product Manager
Schrodinger, LLC

On Fri, Nov 5, 2010 at 4:28 PM, Jose Miguel Cruz Toledo

Reply all
Reply to author
Forward
0 new messages