[vtkusers] Magic VTKPanel include

Liviu Constantinescu liviu at icpfirefly.com.au
Sat May 6 11:45:08 EDT 2006


Having tried and retried, built and rebuilt, I simply can't work out  
why VTK's Java bindings aren't working for me, so I hope you'll  
indulge me this potentially-foolish question:

I'm running VTK 5.0 on Mac OS X 10.4, and have built it using shared  
libraries and Java support. After trying different things all day, I  
eventually got VTK to almost work by installing it as normal for OS  
X, then copying vtk.jar and the following symbolic links into the / 
Library/Java/Extensions folder (ie. into the java.library.path):

libvtkWidgetsJava.jnilib
libvtkVolumeRenderingJava.jnilib
libvtkRenderingJava.jnilib
libvtkIOJava.jnilib
libvtkImagingJava.jnilib
libvtkHybridJava.jnilib
libvtkGraphicsJava.jnilib
libvtkFilteringJava.jnilib
libvtkCommonJava.jnilib

With this done, everything compiles and runs just fine. However, as  
soon as it starts running, each program simply crashes on VTKInit.  
Cone.java (for example), produces the following:

[Tutorial/Step1/Java] liviu% javac Cone.java
[Tutorial/Step1/Java] liviu% java Cone
Exception in thread "main" java.lang.UnsatisfiedLinkError: VTKInit
         at vtk.vtkConeSource.VTKInit(Native Method)
         at vtk.vtkObject.<init>(vtkObject.java:90)
         at vtk.vtkAlgorithm.<init>(vtkAlgorithm.java:238)
         at vtk.vtkPolyDataAlgorithm.<init>(vtkPolyDataAlgorithm.java: 
58)
         at vtk.vtkConeSource.<init>(vtkConeSource.java:114)
         at Cone.main(Cone.java:33)

However, if I edit Cone.java, comment out the following:

  /*static {
     System.loadLibrary("vtkCommonJava");
     System.loadLibrary("vtkFilteringJava");
     System.loadLibrary("vtkIOJava");
     System.loadLibrary("vtkImagingJava");
     System.loadLibrary("vtkGraphicsJava");
     System.loadLibrary("vtkRenderingJava");
   }*/

Then add the line:

vtkPanel testPanel = new vtkPanel();

Suddenly everything works perfectly.

Having looked in the vtkPanel class, I can't for the life of me work  
out what it does that is so different. It loads the same libraries,  
it builds some objects which, if I add them to Cone.java, simply  
cause the same VTKInit error...

What does vtkPanel.java do that Cone.java does not? And how do I make  
java compile VTK apps without having to strip out all their library- 
loads and instantiate vtkPanel instead?

Thanks in advance, getting this Java VTK to work has been driving me  
nuts, and I feel like I'm stuck on some trivial final step I can't  
work out.

-- Liviu



More information about the vtkusers mailing list