[vtkusers] problems running a vtk java bindings example
Sebastien Jourdain
sebastien.jourdain at kitware.com
Wed Oct 28 18:12:15 EDT 2015
Hi Henry,
It is true that getting and understanding how to get your environment setup
is frustrating and the most complex part, specially for Java developers.
But once you figure it out, that's not a big deal anymore.
I guess you do something like that on your linux box to run your app:
$ export LD_LIBRARY_PATH=/usr/local/natives-Linux-x86_64
$ java -cp /path/to/vtk.jar:/your/jar/file.jar Cone
It seems that you've done what is require for the app to work. But as a
side note, it might be safer to use the dedicated enum to load the native
libraries.
// -----------------------------------------------------------------
// Load VTK library and print which library was not properly loaded
static {
if (!vtkNativeLibrary.LoadAllNativeLibraries()) {
for (vtkNativeLibrary lib : vtkNativeLibrary.values()) {
if (!lib.IsLoaded()) {
System.out.println(lib.GetLibraryName() + " not loaded");
}
}
}
vtkNativeLibrary.DisableOutputWindow(null);
}
You can also use that enum to make sure the Library that you try to load is
the correct one too.
Seb
On Wed, Oct 28, 2015 at 11:41 AM, Henry Blanco <henry.blanco at cbiomed.cu>
wrote:
> Hello Sebastien, thanks for your reply. Well, I have done what you
> suggested, but still the program does not find the proper native
> library, in this case: "libvtkCommonCoreJava.so".
>
> This library is placed at "/usr/local/natives-Linux-x86_64", and it is
> also packed into the jar file "vtk-6.1-natives-Linux-x86_64.jar". The
> environment variable $LD_LIBRARY_PATH is set to point to that directory
> (as you suggested). Moreover, I have specify those dependencies in my
> Eclipse IDE as well. You can check all these evidences attached to this
> email as small screenshots.
>
> This is the piece of code that is generating the link error. The linker
> stops when processing the statement:
>
> System.loadLibrary("libvtkCommonCoreJava");
>
> --------------------
> import vtk.*;
> public class Cone {
>
> // In the static constructor we load in the native code.
> // The libraries must be in your path to work.
> static {
>
> // System.loadLibrary("vtkCommonJava");
> // System.loadLibrary("vtkFilteringJava");
> // System.loadLibrary("vtkIOJava");
> // System.loadLibrary("vtkImagingJava");
> // System.loadLibrary("vtkGraphicsJava");
> // System.loadLibrary("vtkRenderingJava");
>
> System.loadLibrary("libvtkCommonCoreJava");
> System.loadLibrary("libvtkFiltersCoreJava");
> System.loadLibrary("libvtkIOCoreJava");
> System.loadLibrary("libvtkImagingCoreJava");
> System.loadLibrary("libvtkRenderingCoreJava");
> }
> ...
> }// End of the class: Cone
>
> Failing to run such a simple example of this library it's a bit
> frustrating for me. I'm looking forward to overcome this issue just to
> start learning this attractive visualization library.
>
> Thanks in advance.
>
> Henry
> --------------------
> On lun, 2015-10-26 at 11:09 -0600, Sebastien Jourdain wrote:
> > Hi Henry,
> >
> >
> > As you noticed, you will need to unzip
> > the vtk-6.1-natives-Linux-x86_64.jar file into a directory and add
> > that directory path to your LD_LIBRARY_PATH environment variable. Then
> > the rest, should follow.
> >
> >
> > Seb
> >
> > On Mon, Oct 26, 2015 at 9:48 AM, Henry Blanco
> > <henry.blanco at cbiomed.cu> wrote:
> > Hello guys, I have set up and compiled VTK through cmake on a
> > 64-bits
> > Ubuntu 14.04, just to get VTK Java bindings, but I have failed
> > to run a
> > simple "Cone.java" example. Specifically, when I try to
> > execute the
> > statement:
> >
> > System.loadLibrary("vtkCommonJava");
> >
> > The compiler throws the following error:
> >
> > Exception in thread "main" java.lang.UnsatisfiedLinkError: no
> > vtkCommonJava in java.library.path
> > at
> > java.lang.ClassLoader.loadLibrary(ClassLoader.java:1886)
> > at java.lang.Runtime.loadLibrary0(Runtime.java:849)
> > at java.lang.System.loadLibrary(System.java:1088)
> > at Cone.<clinit>(Cone.java:17)
> >
> > --------------------------------------
> > To specify what my problem is, please, read these comments:
> >
> > 1- The VTK compilation process produced the following .jar
> > files (both
> > placed at /usr/local/ directory):
> > vtk-6.1.jar
> > vtk-6.1-natives-Linux-x86_64.jar
> >
> > 2- The library files "vtkCommonJava.o" is not among those
> > produced by
> > the compilation process.
> > 3- The most similar library file to "vtkCommonJava" that I
> > have found is
> > "libvtkCommonCoreJava.o", packed into the jar file
> > "vtk-6.1-natives-Linux-x86_64.jar". I have included this file
> > into the
> > "Java Build Path" of my Eclipse IDE, as well as the jar file
> > "vtk-6.1.jar", but still the program fails to run.
> >
> > I will appreciate any suggestions on what is missing here to
> > run the
> > java example. Thanks in advance.
> >
> > Henry
> >
> > _______________________________________________
> > Powered by www.kitware.com
> >
> > Visit other Kitware open-source projects at
> > http://www.kitware.com/opensource/opensource.html
> >
> > Please keep messages on-topic and check the VTK FAQ at:
> > http://www.vtk.org/Wiki/VTK_FAQ
> >
> > Search the list archives at:
> > http://markmail.org/search/?q=vtkusers
> >
> > Follow this link to subscribe/unsubscribe:
> > http://public.kitware.com/mailman/listinfo/vtkusers
> >
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20151028/ac4a2e00/attachment.html>
More information about the vtkusers
mailing list