posted on: 2009-03-07 09:40:47
Getting VTK up and running with the java wrapper.

>So as I have described with Python I compiled VTK, but this time I included the java wrapping. Great the keys were getting all of the java environment variables correct. Here they are:

JAVA_INCLUDE_PATH, points to location of the file jni.h ie


JAVA_INCLUDE_PATH2, points to location of the file jni_md.h, which is a system specific file.


JAVA_AWT_INCLUDE_PATH, points to the location of jawt.h


JAVA_AWT_LIBRARY, points to a


JAVA_JVM_LIBRARY, points to the


The next step got a little more rough. Again as with python you need to set your environment variables AND you have to load the library files from inside of your java program.

'Exception in thread "main" java.lang.UnsatisfiedLinkError: no vtkCommonJava in java.library.path
	at java.lang.ClassLoader.loadLibrary(
	at java.lang.Runtime.loadLibrary0(
	at java.lang.System.loadLibrary(
	at new_cone.<clinit>(\n'

This is take care of by setting the following environment variables:

export LD_LIBRARY_PATH={vtk_install}/bin:/usr/lib/jvm/java-6-sun-

the first directory has your lib** files in it, while the second directory has the file "", if you don't have the second directory you will get the following error:

'Exception in thread "main" java.lang.UnsatisfiedLinkError: {vtk_install}/ cannot open shared object file:

Now with the environment paths configured correctly you are still going to get an unsatisfied link error, so you have to load your libraries:

   static {
       System.out.println("works to here");

So easy and yet it can take some time to figure out. Lastly here is an example using the window interactor.

Note you should have some examples that come with your vtk installation, If I had started from these I would have been done much quicker.