[vtk-developers] Selecting libraries

CSharpdotcom . csharpdotcom at gmail.com
Tue Mar 31 13:47:09 EDT 2015


Hello,

I've just been trying another Java example of VTK, as listed in
http://www.vtk.org/Wiki/VTK/Examples/Java/Cylinder, which I put into
NetBeans.  When I use the code in the static block:

static {
    System.loadLibrary("vtkCommonCoreJava");
    System.loadLibrary("vtkFiltersSourcesJava");
    System.loadLibrary("vtkInteractionStyleJava");
    System.loadLibrary("vtkRenderingOpenGLJava");
  }

as given in the listing, the application fails with the error message:

Exception in thread "main" java.lang.UnsatisfiedLinkError:
vtk.vtkPolyDataMapper.VTKInit()J
..........

and I found that VTKInit() is called right at the very end of the
vtkPolyData class in vtk.jar.  However, if I replace loading the
specified libraries in the static block above by loading all the
libraries using:

static {
    if (!vtkNativeLibrary.LoadAllNativeLibraries()) {
        for (vtkNativeLibrary lib : vtkNativeLibrary.values()) {
            if (!lib.IsLoaded())
              System.out.println(lib.GetLibraryName() + " not loaded");
        }
        System.out.println("Make sure the search path is correct: ");
        System.out.println(System.getProperty("java.library.path"));
    }
    vtkNativeLibrary.DisableOutputWindow(null);
}

as copied from the code I got working last week, then the application
works correctly.

My questions are:

1) Is there a way of fixing the error without loading all the libraries?

2) Related to that, is there a way of determining which libraries to
load, without having to load them all?

3) Is it better to load only the libraries you need rather than
loading them all?  This of course will depend on knowing which
libraries to load from (2).

At your convenience I would be grateful to have some help on this.

Christopher Sharp


More information about the vtk-developers mailing list