[vtkusers] Problem to develop vtk-java applet applications.

Aurora on web aurora-web at live.jp
Tue Feb 3 04:56:00 EST 2009


Hi every one.

I'm working on a interactive vtk model viewer with java applet.
This is the 1st time I tried to develop the vtk-java applet.

I already have built vtk-java library and "vtk.jar" and confirmed
that stand-alone vtk-java application (not java applet) were able to be
compiled and excuted with java command like below successfully.

============================================================
G:\MyProjects\Java\vtkSamples>javac -classpath G:\MyProjects\Java\vtkSample\vtk.jar;G:\MyProjects\Java\vtkSamples Simple.java

G:\MyProjects\Java\vtkSamples>java -classpath G:\MyProjects\Java\vtkSample\vtk.jar;G:\MyProjects\Java\vtkSamples Simple
============================================================
The vtk.jar was obtained in C:\MyTemp\Build\Development\vtk-5.2.0\binary\bin
where I built vtk 5.2.0 for java.

However, I failed to excute very simple vtk-java program which
renders the cone object.
(In compilation with javac, there were no cautions. but applet on
browser displayed nothing and java console output some errors.)

I show you the code and what I did on command prompt.

Code of "SimpleApplet.java"
------------------------------------------------------------
import java.applet.*;
import java.awt.*;
import vtk.*;
public class SimpleApplet extends Applet{
  public void init() {
    vtkPanel panel = new vtkPanel();
    vtkConeSource cs = new vtkConeSource();
    cs.SetRadius(2);
    cs.SetAngle(15);
    cs.SetHeight(1);
    
    vtkPolyDataMapper map = new vtkPolyDataMapper();
    vtkActor actor = new vtkActor();
    map.SetInput(cs.GetOutput());
    actor.SetMapper(map);
    
    panel.GetRenderer().AddActor(actor);
    
    add(panel, "Center");
    }
}
------------------------------------------------------------


Compilation of "SimpleApplet.java" and construction of jar
============================================================
G:\MyProjects\Java\vtkSamples>javac -classpath G:\MyProjects\Java\vtkSample\vtk.jar;G:\MyProjects\Java\vtkSamples SimpleApplet.java

G:\MyProjects\Java\vtkSamples>jar cvf SimpleApplet.jar SimpleApplet.class vtk.jar
============================================================

And I make a html file which call the applet.

Source of "SimpleApplet.html"
------------------------------------------------------------


    vtk applet testing








------------------------------------------------------------

I got some error messages on the java console display.

------------------------------------------------------------
java.lang.NoClassDefFoundError: vtk/vtkMapper
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
    at java.lang.Class.getConstructor0(Unknown Source)
    at java.lang.Class.newInstance0(Unknown Source)
    at java.lang.Class.newInstance(Unknown Source)
    at sun.applet.AppletPanel.createApplet(Unknown Source)
    at sun.plugin.AppletViewer.createApplet(Unknown Source)
    at sun.applet.AppletPanel.runLoader(Unknown Source)
    at sun.applet.AppletPanel.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: vtk.vtkMapper
    at sun.applet.AppletClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.applet.AppletClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    ... 10 more

------------------------------------------------------------

I've searched some explanation about java-vtk applet.
Some old documents says "vtkdll.dll, vtkjava.dll, and vtk.jar are
required" but I can't find vtkdll.dll and vtkjava.dll in the
build directory.

What's wrong with developing class and jar file and calling it
from browser?

I would be happy if someone know how to make java-vtk applet properly
and answer my questions.

Thank you very much.



_________________________________________________________________
【無料】メッセで使える動画絵文字『ひとこと動画』を使おう【配信中】
http://ch.nicovideo.jp/channel/ch168



More information about the vtkusers mailing list