Automatic-Module-Name: vtk
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: vtk
+Bundle-ActivationPolicy: lazy
+Bundle-Activator: vtk.Activator
+Require-Bundle: org.eclipse.core.runtime;bundle-version="3.13.0"
--- /dev/null
+package vtk;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator implements BundleActivator {
+
+ @Override
+ public void start(BundleContext context) throws Exception {
+ vtkJavaDep.load();
+
+ }
+
+ @Override
+ public void stop(BundleContext context) throws Exception {
+
+ }
+
+}
*/
public class vtkJavaDep {
static String[] libs = new String[] {
- "jawt",
"vtksys",
"vtkCommonCore",
"vtkWrappingJava",
"vtkIOImportJava",
};
+
+ private static boolean loaded = false;
+ static void load() {
+ if (!loaded) {
- static {
- try {
- Class.forName("java.awt.Toolkit");
- } catch (ClassNotFoundException e) {
- throw new IllegalStateException(e);
- }
+ try {
+ Class.forName("java.awt.Toolkit");
+ } catch (ClassNotFoundException e) {
+ throw new IllegalStateException(e);
+ }
+ try {
+ System.loadLibrary("jawt");
+ } catch (UnsatisfiedLinkError e) {
+ // bypass potential load error. If jawt is not really loaded, we will get errors
+ // with VTK dlls.
+ }
- for (String lib : libs)
- System.loadLibrary(lib);
- }
-
- static void load() {
+ for (String lib : libs)
+ System.loadLibrary(lib);
+ loaded = true;
+ }
}
}
public static vtk.vtkJavaMemoryManager JAVA_OBJECT_MANAGER = new vtk.vtkJavaMemoryManagerImpl();
public vtkObjectBase() {
- vtkJavaDep.load();
this.vtkId = this.VTKInit();
vtkObjectBase.JAVA_OBJECT_MANAGER.registerJavaObject(this.vtkId, this);
}